Python Quiz Program
Basic Python Quiz Program
quiz = {
"question1": {
"question": "What is the capital city of Pakistan?",
"answer": "Islamabad"
},
"question2": {
"question": "When Pakistan separated from India?",
"answer": "1947"
},
"question3": {
"question": "What is the name of the tallest mountain in the world?",
"answer": "Everest"
},
"question4": {
"question": "What is the name of the nearest planet to the sun?",
"answer": "Mercury"
},
"question5": {
"question": "Our sun is a star? Yes or No?",
"answer": "Yes"
}
}
score = 0
for key, value in quiz.items():
print("")
print(value["question"])
correctAnswer = value["answer"].lower()
answer = input("Plz enter your answer: ").lower()
if answer == correctAnswer:
score += 1
print("Your answer is correct.")
print(f"Your score now is {score}")
else:
print("Your answer is NOT correct.")
print("The correct answer is",value["answer"])
print(f"Your score is {score}")
print("\nResult:")
print(f"Your total score is {score}")
print(f"Your score percentage is {score/5*100}%")
Comments
Post a Comment
Write something to CodeWithAbdur!