Code:
# text based Quiz Game
# making a variable to store total marks
marks = 0
# Greet the user if he/she wants to play
answer = input("Do you want to play? ")
if answer.lower() == 'yes':
print("Let's Start the game")
else:
print("Ok come back next time!")
exit()
# Asking the first question
answer = input("Who invented the BALLPOINT PEN? ")
# lower() coverts the each alphabet
# of string into lower case
if answer.lower() == 'biro brothers':
print("Correct")
# if user give correct answer increment marks by 1
marks += 1
else:
print("Incorrect")
answer = input("What J. B. Dunlop invented? ")
if answer.lower() == 'pneumatic rubber tire':
print("Correct")
marks += 1
else:
print("Incorrect")
answer = input("What Galileo invented? ")
if answer.lower() == 'thermometer':
print("Correct")
marks += 1
else:
print("Incorrect")
answer = input("This English inventor is known as the 'Father of Computing.' ")
if answer.lower() == 'charles babbage':
print("Correct")
marks += 1
else:
print("Incorrect")
answer = input("For whom high heeled shoes were invented? ")
if answer.lower() == 'King Louis':
print("Correct")
marks += 1
else:
print("Incorrect")
# Decisions based on marks
if marks < 2:
print("Try again")
# elif short for if else
elif marks <= 3:
print("You tried better")
elif marks > 3:
print("Good job you did it Congrats")
# Printing the percentage of correct answers
print("You got " + str((marks/5) * 100) + "% marks")
"Keep Good care of your Health
Allah Hafiz and Good Bye Till the next post"
"Keep Learning and Keep exploring"
Love me like you do