repl.it
@AidanMundle/

Quiz Game

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import random
counter=0;
 
capital = { 'Ontario': 'Toronto', 'Manitoba':'Winnipeg', 
            'Saskatchewan':'Regina', 'Alberta':'Edmonton',
            'British Columbia':'Victoria', 'Prince Edward Island':'Charlottetown',
            'Newfoundland':"St. John's", 'Nova Scotia':'Halifax',
            'New Brunswick':'Fredricton','Quebec':'Quebec City'}

for j in range (5):
# Select capitals randomly
  provinces = list( capital.keys() )
  questions = []
  for i in range(5):
    n = random.randint( 0, len(provinces)-1 )
    questions.append( provinces[n] )
    provinces.pop(n)

#print( questions )
#print( provinces )


  ans = input('What is the capital of ' + questions[0] + '? ')

  if ans == capital[ questions[0] ]:
    print('Correct')
    counter+=1
  else:
    print('Incorrect. The capital of ' + 'Ontario' + ' is ' + capital[ questions[0] ] + '.')
  print()
  
print("Congrats! You scored", counter,"/ 5!")
print("Play again? Press CTRL+Enter")
Fetching token
?