Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ask_q(prompt, ans):
- usr_try = input(prompt + '?: ')
- if usr_try == ans:
- return True
- else:
- return False
- questions = {'When was the Weimar republic abolished': '1933',
- 'Was Adolf Hitler German-born?': 'No'}
- print('Welcome to your history revision mini-test!')
- while True:
- start = input('Begin? (y/n): ')
- if start != 'y':
- break
- mark = 0
- for q, a in questions.items():
- test = ask_q(q, a)
- if test:
- print('Correct!')
- mark += 1
- else:
- print('Incorrect. The answer was: ', a)
- print('You scored {score}/{most}!'.format(score=mark, most=len(questions)))
- print('Goodbye!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement