lundi 22 février 2016

Quiz making using id/else statements and random variables/dictionaries/lists

Quiz making instructions

I started my code somewhat

from random import randint, shuffle

numbers = {1:'\u4e00', 2:'\u4e8c', 3:'\u4e09', 4:'\u56db', 5:'\u4e94', \
    6:'\u516d', 7:'\u4e03', 8:'\u516b', 9:'\u4e5d', 10:'\u5341'}

x=randint(1,10)



print('Welcome to our quiz on Chinese/Japanese numerals.')

input('What is the Value of ' +numbers[x]  +'?' )


if 1 == '\u4e00' : 
    print('Congratulations! Let us continue then, consider:')
else:
    print( 'Congratulations! Let us continue then, consider:')
    input (['\u4e00', '\u4e8c', '\u4e09', '\u56db','\u4e94', \
    '\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'])
    input ('At which position is the value of ' +numbers[x] +'?' )

I'm having issues with the if and else portion of the code. I have been able to set up the beginning of the quiz by asking the initial question and inserting the random Chinese character, however I'm having an issue following it up with the "Wrong answer, ____ equals _____." part of the statement. How do i establish that what the user inserts into the prompt is correct or incorrect?




Aucun commentaire:

Enregistrer un commentaire