Question: Write a Python program which will quiz a user about the capital city of each province in Canada. The program should do the following:
Write a Python program which will quiz a user about the capital city of each province in Canada. The program should do the following: Allow only 3 guesses for each province. Display the guess number Quiz all 10 provinces Output a message, when user guesses correctly. Sample output screen: What is the capital of Newfoundland? Guess 1: Guess 2: Guess 3: ...St. John's ...St. John ...St. Johns Correct! What is the capital of Prince Edward Island? Guess 1: *** After you completed the quiz for all 10 provinces, then modify the program so that it will display the number of right and wrong answers at the end of the quiz. It will also display the users score as a percentage mark (e.g., 90%) Bonus marks given if you add the Canadian territories. Sample output screen: Correct! What is the capital of Saskatchewan? Guess 1: ... Regina Correct! What is the capital of Alberta? Guess 1: ...Edmonton Correct! What is the capital of British Columbia? Guess 1: ...Victoria Correct! You got 7 right and made 3 wrong guesses. Your total score is 70.0% >>> import random num1 = random.randint(1, num2 = random.randint(1, 5) 5) guess = int(input("Enter the first number randomly generated")) while guess != num1: print("your guess is wrong") guess = int(input("Enter the first number randomly generated")) guess2 = int(input("Enter the second number randomly generated")) while guess2 != num2: print("your guess is wrong") guess2 = int(input("Enter the second number randomly generated")) print("Good you guessed both numbers correctly") def address(): print("12 Shakespere Rd") print("New Jersey") def no_response(): print("It's ok") print("I don't know it off by heart") answer=input("Do you want my adress?") if answer == "yes": address() elif answer == "no" no_response() else: print("I dont understand") 2020
Step by Step Solution
3.48 Rating (155 Votes )
There are 3 Steps involved in it
Heres a Python program that quizzes the user about the capital cities of Canadian provinces and then ... View full answer
Get step-by-step solutions from verified subject matter experts
