Python Programming - Multiple Choice Quiz

preview_player
Показать описание
Welcome to Part 11 of the Python Programming tutorial series here on Tutorial Spot.

In Part 11 I demonstrate how we can use print, input and conditions to create a quiz. This time we look at giving the user a choice of answers and then they enter the corresponding letter.

Python 3.6.4 was used to make this tutorial.

Twitter: @TutorialSpotUK
Рекомендации по теме
Комментарии
Автор

Beautiful class! Thank you so much! Strait forward! Truly appreciate you being here!

HIDlarissaTERRY
Автор

Cool! I found in another tutorial that you can set the variable "answer" to be like this:

answer = input().upper()

This turns whatever the user inputs into uppercase characters. Then you can save time for making if statements, if you desire to use different letters for the other answers.

Husholdninger
Автор

Thanks mate, you got me a 9- on my homework. (That's like an A*)

bogney
Автор

Hey would you happen to know how to repeat the chunk of code to allow the user to try again without copy and pasting it?

beniyum
Автор

print ("Welcome to my quiz!")
name= input()
print ("What is your, name")
print ("Welcome to my quiz")
print(name)
question1 = input ("Who is the current president of United States?")
answer1 = ("Barack Obama") or ("barack obama")
if question1 == answer1:
    print("correct!")
elif question1 != answer1:
    print("Incorrect!")
question2 = input ("What is the capital of France ?")
answer2 = ("Paris") or ("paris")
if question2 == answer2:
    print ("correct!")
elif question2 != answer2:
    print("Incorrect!")   
goodbye = input("Thanks for playing! Press enter to exit")

ahmadalmohamad