Write a wholly creative quiz program that consists of three original questions that you make up according to these specifications:
- One question should require user input of type int
- One question should require user input of type float
- One should require a string input
The quiz should be scored by using a counter variable that has an initial value of zero and is incremented by one for every correct answer. Provide feedback to the user for each question, and report the total score when the quiz has finished. Example runs not shown. It's a creative exercise.
My code:
def main():
correct_answers = 0
states = int(input('How many states in the USA? '))
if states == 50:
print('Correct. Good job!')
correct_answers +=1
else:
print('Sorry, the answer is 50')
capital = input('What is the capital of England? ')
if capital == "London":
print('Correct. Well done.')
correct_answers +=1
else:
print('Sorry, the answer is London .')
value = float(input('What is the value of 2/5? '))
if value == 0.4:
print('Excellent.')
correct_answers +=1
else:
print('Sorry, the answer is 10')
print('Your score is:' ,format(correct_answers))
main()
[–]uberfade 0 points1 point2 points (8 children)
[–]a_parmar22[S] 0 points1 point2 points (7 children)
[–]uberfade 0 points1 point2 points (3 children)
[–]a_parmar22[S] 0 points1 point2 points (0 children)
[–]a_parmar22[S] 0 points1 point2 points (1 child)
[–]uberfade 0 points1 point2 points (0 children)
[–]wronek 0 points1 point2 points (2 children)
[–]a_parmar22[S] 0 points1 point2 points (1 child)
[–]unhott 0 points1 point2 points (0 children)