-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCapital Quiz A Game to Test Your Geography Knowledge.py
282 lines (268 loc) · 15.4 KB
/
Capital Quiz A Game to Test Your Geography Knowledge.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/env python
# coding: utf-8
# In[4]:
import random
# Dictionary of countries with their information
countries_info = {
"Afghanistan": {"abbreviation": "AF", "capital": "Kabul"},
"Albania": {"abbreviation": "AL", "capital": "Tirana"},
"Algeria": {"abbreviation": "DZ", "capital": "Algiers"},
"Alabama": {"abbreviation": "AL", "capital": "Montgomery"},
"Alaska": {"abbreviation": "AK", "capital": "Juneau"},
"Arizona": {"abbreviation": "AZ", "capital": "Phoenix"},
"Arkansas": {"abbreviation": "AR", "capital": "Little Rock"},
"California": {"abbreviation": "CA", "capital": "Sacramento"},
"Colorado": {"abbreviation": "CO", "capital": "Denver"},
"Connecticut": {"abbreviation": "CT", "capital": "Hartford"},
"Delaware": {"abbreviation": "DE", "capital": "Dover"},
"Florida": {"abbreviation": "FL", "capital": "Tallahassee"},
"Georgia": {"abbreviation": "GA", "capital": "Atlanta"},
"Hawaii": {"abbreviation": "HI", "capital": "Honolulu"},
"Idaho": {"abbreviation": "ID", "capital": "Boise"},
"Illinois": {"abbreviation": "IL", "capital": "Springfield"},
"Indiana": {"abbreviation": "IN", "capital": "Indianapolis"},
"Iowa": {"abbreviation": "IA", "capital": "Des Moines"},
"Kansas": {"abbreviation": "KS", "capital": "Topeka"},
"Kentucky": {"abbreviation": "KY", "capital": "Frankfort"},
"Louisiana": {"abbreviation": "LA", "capital": "Baton Rouge"},
"Maine": {"abbreviation": "ME", "capital": "Augusta"},
"Maryland": {"abbreviation": "MD", "capital": "Annapolis"},
"Massachusetts": {"abbreviation": "MA", "capital": "Boston"},
"Michigan": {"abbreviation": "MI", "capital": "Lansing"},
"Minnesota": {"abbreviation": "MN", "capital": "Saint Paul"},
"Mississippi": {"abbreviation": "MS", "capital": "Jackson"},
"Missouri": {"abbreviation": "MO", "capital": "Jefferson City"},
"Montana": {"abbreviation": "MT", "capital": "Helena"},
"Nebraska": {"abbreviation": "NE", "capital": "Lincoln"},
"Nevada": {"abbreviation": "NV", "capital": "Carson City"},
"New Hampshire": {"abbreviation": "NH", "capital": "Concord"},
"New Jersey": {"abbreviation": "NJ", "capital": "Trenton"},
"New Mexico": {"abbreviation": "NM", "capital": "Santa Fe"},
"New York": {"abbreviation": "NY", "capital": "Albany"},
"North Carolina": {"abbreviation": "NC", "capital": "Raleigh"},
"North Dakota": {"abbreviation": "ND", "capital": "Bismarck"},
"Ohio": {"abbreviation": "OH", "capital": "Columbus"},
"Oklahoma": {"abbreviation": "OK", "capital": "Oklahoma City"},
"Oregon": {"abbreviation": "OR", "capital": "Salem"},
"Pennsylvania": {"abbreviation": "PA", "capital": "Harrisburg"},
"Rhode Island": {"abbreviation": "RI", "capital": "Providence"},
"Afghanistan": {"abbreviation": "AF", "capital": "Kabul"},
"Albania": {"abbreviation": "AL", "capital": "Tirana"},
"Algeria": {"abbreviation": "DZ", "capital": "Algiers"},
"Andorra": {"abbreviation": "AD", "capital": "Andorra la Vella"},
"Angola": {"abbreviation": "AO", "capital": "Luanda"},
"Antigua and Barbuda": {"abbreviation": "AG", "capital": "Saint John's"},
"Argentina": {"abbreviation": "AR", "capital": "Buenos Aires"},
"Armenia": {"abbreviation": "AM", "capital": "Yerevan"},
"Australia": {"abbreviation": "AU", "capital": "Canberra"},
"Austria": {"abbreviation": "AT", "capital": "Vienna"},
"Azerbaijan": {"abbreviation": "AZ", "capital": "Baku"},
"Bahamas": {"abbreviation": "BS", "capital": "Nassau"},
"Bahrain": {"abbreviation": "BH", "capital": "Manama"},
"Bangladesh": {"abbreviation": "BD", "capital": "Dhaka"},
"Barbados": {"abbreviation": "BB", "capital": "Bridgetown"},
"Belarus": {"abbreviation": "BY", "capital": "Minsk"},
"Belgium": {"abbreviation": "BE", "capital": "Brussels"},
"Belize": {"abbreviation": "BZ", "capital": "Belmopan"},
"Benin": {"abbreviation": "BJ", "capital": "Porto-Novo"},
"Bhutan": {"abbreviation": "BT", "capital": "Thimphu"},
"Bolivia": {"abbreviation": "BO", "capital": "Sucre"},
"Bosnia and Herzegovina": {"abbreviation": "BA", "capital": "Sarajevo"},
"Botswana": {"abbreviation": "BW", "capital": "Gaborone"},
"Brazil": {"abbreviation": "BR", "capital": "Brasília"},
"Brunei": {"abbreviation": "BN", "capital": "Bandar Seri Begawan"},
"Bulgaria": {"abbreviation": "BG", "capital": "Sofia"},
"Burkina Faso": {"abbreviation": "BF", "capital": "Ouagadougou"},
"Burundi": {"abbreviation": "BI", "capital": "Gitega"},
"Cambodia": {"abbreviation": "KH", "capital": "Phnom Penh"},
"Cameroon": {"abbreviation": "CM", "capital": "Yaoundé"},
"Canada": {"abbreviation": "CA", "capital": "Ottawa"},
"Cape Verde": {"abbreviation": "CV", "capital": "Praia"},
"Central African Republic": {"abbreviation": "CF", "capital": "Bangui"},
"Chad": {"abbreviation": "TD", "capital": "N'Djamena"},
"Chile": {"abbreviation": "CL", "capital": "Santiago"},
"China": {"abbreviation": "CN", "capital": "Beijing"},
"Colombia": {"abbreviation": "CO", "capital": "Bogotá"},
"Comoros": {"abbreviation": "KM", "capital": "Moroni"},
"Congo (Brazzaville)": {"abbreviation": "CG", "capital": "Brazzaville"},
"Congo (Kinshasa)": {"abbreviation": "CD", "capital": "Kinshasa"},
"Costa Rica": {"abbreviation": "CR", "capital": "San José"},
"Croatia": {"abbreviation": "HR", "capital": "Zagreb"},
"Cuba": {"abbreviation": "CU", "capital": "Havana"},
"Cyprus": {"abbreviation": "CY", "capital": "Nicosia"},
"Czech Republic": {"abbreviation": "CZ", "capital": "Prague"},
"Denmark": {"abbreviation": "DK", "capital": "Copenhagen"},
"Djibouti": {"abbreviation": "DJ", "capital": "Djibouti"},
"Dominica": {"abbreviation": "DM", "capital": "Roseau"},
"Dominican Republic": {"abbreviation": "DO", "capital": "Santo Domingo"},
"East Timor": {"abbreviation": "TL", "capital": "Dili"},
"Ecuador": {"abbreviation": "EC", "capital": "Quito"},
"Egypt": {"abbreviation": "EG", "capital": "Cairo"},
"El Salvador": {"abbreviation": "SV", "capital": "San Salvador"},
"Equatorial Guinea": {"abbreviation": "GQ", "capital": "Malabo"},
"Eritrea": {"abbreviation": "ER", "capital": "Asmara"},
"Estonia": {"abbreviation": "EE", "capital": "Tallinn"},
"Eswatini (Swaziland)": {"abbreviation": "SZ", "capital": "Mbabane"},
"Ethiopia": {"abbreviation": "ET", "capital": "Addis Ababa"},
"Fiji": {"abbreviation": "FJ", "capital": "Suva"},
"Finland": {"abbreviation": "FI", "capital": "Helsinki"},
"France": {"abbreviation": "FR", "capital": "Paris"},
"Gabon": {"abbreviation": "GA", "capital": "Libreville"},
"Gambia": {"abbreviation": "GM", "capital": "Banjul"},
"Georgia": {"abbreviation": "GE", "capital": "Tbilisi"},
"Germany": {"abbreviation": "DE", "capital": "Berlin"},
"Ghana": {"abbreviation": "GH", "capital": "Accra"},
"Greece": {"abbreviation": "GR", "capital": "Athens"},
"Grenada": {"abbreviation": "GD", "capital": "Saint George's"},
"Guatemala": {"abbreviation": "GT", "capital": "Guatemala City"},
"Guinea": {"abbreviation": "GN", "capital": "Conakry"},
"Guinea-Bissau": {"abbreviation": "GW", "capital": "Bissau"},
"Guyana": {"abbreviation": "GY", "capital": "Georgetown"},
"Haiti": {"abbreviation": "HT", "capital": "Port-au-Prince"},
"Honduras": {"abbreviation": "HN", "capital": "Tegucigalpa"},
"Hungary": {"abbreviation": "HU", "capital": "Budapest"},
"Iceland": {"abbreviation": "IS", "capital": "Reykjavik"},
"India": {"abbreviation": "IN", "capital": "New Delhi"},
"Indonesia": {"abbreviation": "ID", "capital": "Jakarta"},
"Iran": {"abbreviation": "IR", "capital": "Tehran"},
"Iraq": {"abbreviation": "IQ", "capital": "Baghdad"},
"Ireland": {"abbreviation": "IE", "capital": "Dublin"},
"Israel": {"abbreviation": "IL", "capital": "Jerusalem"},
"Italy": {"abbreviation": "IT", "capital": "Rome"},
"Ivory Coast": {"abbreviation": "CI", "capital": "Yamoussoukro"},
"Jamaica": {"abbreviation": "JM", "capital": "Kingston"},
"Japan": {"abbreviation": "JP", "capital": "Tokyo"},
"Jordan": {"abbreviation": "JO", "capital": "Amman"},
"Kazakhstan": {"abbreviation": "KZ", "capital": "Nur-Sultan"},
"Kenya": {"abbreviation": "KE", "capital": "Nairobi"},
"Kiribati": {"abbreviation": "KI", "capital": "South Tarawa"},
"Kosovo": {"abbreviation": "XK", "capital": "Pristina"},
"Kuwait": {"abbreviation": "KW", "capital": "Kuwait City"},
"Kyrgyzstan": {"abbreviation": "KG", "capital": "Bishkek"},
"Laos": {"abbreviation": "LA", "capital": "Vientiane"},
"Latvia": {"abbreviation": "LV", "capital": "Riga"},
"Lebanon": {"abbreviation": "LB", "capital": "Beirut"},
"Lesotho": {"abbreviation": "LS", "capital": "Maseru"},
"Liberia": {"abbreviation": "LR", "capital": "Monrovia"},
"Libya": {"abbreviation": "LY", "capital": "Tripoli"},
"Liechtenstein": {"abbreviation": "LI", "capital": "Vaduz"},
"Lithuania": {"abbreviation": "LT", "capital": "Vilnius"},
"Luxembourg": {"abbreviation": "LU", "capital": "Luxembourg"},
"Madagascar": {"abbreviation": "MG", "capital": "Antananarivo"},
"Malawi": {"abbreviation": "MW", "capital": "Lilongwe"},
"Malaysia": {"abbreviation": "MY", "capital": "Kuala Lumpur"},
"Maldives": {"abbreviation": "MV", "capital": "Malé"},
"Mali": {"abbreviation": "ML", "capital": "Bamako"},
"Malta": {"abbreviation": "MT", "capital": "Valletta"},
"Marshall Islands": {"abbreviation": "MH", "capital": "Majuro"},
"Mauritania": {"abbreviation": "MR", "capital": "Nouakchott"},
"Mauritius": {"abbreviation": "MU", "capital": "Port Louis"},
"Mexico": {"abbreviation": "MX", "capital": "Mexico City"},
"Micronesia": {"abbreviation": "FM", "capital": "Palikir"},
"Moldova": {"abbreviation": "MD", "capital": "Chișinău"},
"Monaco": {"abbreviation": "MC", "capital": "Monaco"},
"Mongolia": {"abbreviation": "MN", "capital": "Ulaanbaatar"},
"Montenegro": {"abbreviation": "ME", "capital": "Podgorica"},
"Morocco": {"abbreviation": "MA", "capital": "Rabat"},
"Mozambique": {"abbreviation": "MZ", "capital": "Maputo"},
"Myanmar (Burma)": {"abbreviation": "MM", "capital": "Naypyidaw"},
"Namibia": {"abbreviation": "NA", "capital": "Windhoek"},
"Nauru": {"abbreviation": "NR", "capital": "Yaren"},
"Nepal": {"abbreviation": "NP", "capital": "Kathmandu"},
"Netherlands": {"abbreviation": "NL", "capital": "Amsterdam"},
"New Zealand": {"abbreviation": "NZ", "capital": "Wellington"},
"Nicaragua": {"abbreviation": "NI", "capital": "Managua"},
"Niger": {"abbreviation": "NE", "capital": "Niamey"},
"Nigeria": {"abbreviation": "NG", "capital": "Abuja"},
"North Korea": {"abbreviation": "KP", "capital": "Pyongyang"},
"North Macedonia": {"abbreviation": "MK", "capital": "Skopje"},
"Norway": {"abbreviation": "NO", "capital": "Oslo"},
"Oman": {"abbreviation": "OM", "capital": "Muscat"},
"Pakistan": {"abbreviation": "PK", "capital": "Islamabad"},
"Palau": {"abbreviation": "PW", "capital": "Ngerulmud"},
"Panama": {"abbreviation": "PA", "capital": "Panama City"},
"Papua New Guinea": {"abbreviation": "PG", "capital": "Port Moresby"},
"Paraguay": {"abbreviation": "PY", "capital": "Asunción"},
"Peru": {"abbreviation": "PE", "capital": "Lima"},
"Philippines": {"abbreviation": "PH", "capital": "Manila"},
"Poland": {"abbreviation": "PL", "capital": "Warsaw"},
"Portugal": {"abbreviation": "PT", "capital": "Lisbon"},
"Qatar": {"abbreviation": "QA", "capital": "Doha"},
"Romania": {"abbreviation": "RO", "capital": "Bucharest"},
"Russia": {"abbreviation": "RU", "capital": "Moscow"},
"Rwanda": {"abbreviation": "RW", "capital": "Kigali"},
"Saint Kitts and Nevis": {"abbreviation": "KN", "capital": "Basseterre"},
"Saint Lucia": {"abbreviation": "LC", "capital": "Castries"},
"Saint Vincent and the Grenadines": {"abbreviation": "VC", "capital": "Kingstown"},
"Samoa": {"abbreviation": "WS", "capital": "Apia"},
"San Marino": {"abbreviation": "SM", "capital": "San Marino"},
"Sao Tome and Principe": {"abbreviation": "ST", "capital": "São Tomé"},
"Saudi Arabia": {"abbreviation": "SA", "capital": "Riyadh"},
"Senegal": {"abbreviation": "SN", "capital": "Dakar"},
"Serbia": {"abbreviation": "RS", "capital": "Belgrade"},
"Seychelles": {"abbreviation": "SC", "capital": "Victoria"},
"Sierra Leone": {"abbreviation": "SL", "capital": "Freetown"},
"Singapore": {"abbreviation": "SG", "capital": "Singapore"},
"Slovakia": {"abbreviation": "SK", "capital": "Bratislava"},
"Slovenia": {"abbreviation": "SI", "capital": "Ljubljana"},
"Solomon Islands": {"abbreviation": "SB", "capital": "Honiara"},
"Somalia": {"abbreviation": "SO", "capital": "Mogadishu"},
"South Africa": {"abbreviation": "ZA", "capital": "Pretoria"},
"South Korea": {"abbreviation": "KR", "capital": "Seoul"},
"South Sudan": {"abbreviation": "SS", "capital": "Juba"},
"Spain": {"abbreviation": "ES", "capital": "Madrid"},
"Sri Lanka": {"abbreviation": "LK", "capital": "Sri Jayawardenepura Kotte"},
"Sudan": {"abbreviation": "SD", "capital": "Khartoum"},
"Suriname": {"abbreviation": "SR", "capital": "Paramaribo"},
"Sweden": {"abbreviation": "SE", "capital": "Stockholm"},
"Switzerland": {"abbreviation": "CH", "capital": "Bern"},
"Syria": {"abbreviation": "SY", "capital": "Damascus"},
"Taiwan": {"abbreviation": "TW", "capital": "Taipei"},
"Tajikistan": {"abbreviation": "TJ", "capital": "Dushanbe"},
"Tanzania": {"abbreviation": "TZ", "capital": "Dodoma"},
"Thailand": {"abbreviation": "TH", "capital": "Bangkok"},
"Togo": {"abbreviation": "TG", "capital": "Lomé"},
"Tonga": {"abbreviation": "TO", "capital": "Nuku'alofa"},
"Trinidad and Tobago": {"abbreviation": "TT", "capital": "Port of Spain"},
"Tunisia": {"abbreviation": "TN", "capital": "Tunis"},
"Turkey": {"abbreviation": "TR", "capital": "Ankara"},
"Turkmenistan": {"abbreviation": "TM", "capital": "Ashgabat"},
"Tuvalu": {"abbreviation": "TV", "capital": "Funafuti"},
"Uganda": {"abbreviation": "UG", "capital": "Kampala"},
"Ukraine": {"abbreviation": "UA", "capital": "Kyiv"},
"United Arab Emirates": {"abbreviation": "AE", "capital": "Abu Dhabi"},
"United Kingdom": {"abbreviation": "GB", "capital": "London"},
"United States": {"abbreviation": "US", "capital": "Washington, D.C."},
"Zambia": {"abbreviation": "ZM", "capital": "Lusaka"},
"Zimbabwe": {"abbreviation": "ZW", "capital": "Harare"},
}
def get_random_country():
"""
Returns a random country from the countries_info dictionary.
"""
return random.choice(list(countries_info.keys()))
def get_capital(country):
"""
Returns the capital of the given country.
"""
return countries_info[country]["capital"]
def main():
"""
Main function to run the capital quiz.
"""
print("Capital Quiz: A Game to Test Your Geography Knowledge")
print("==================================================")
while True:
country = get_random_country()
capital = get_capital(country)
guess = input(f"What is the capital of {country}? ")
if guess.lower() == capital.lower():
print("Correct!")
else:
print(f"Sorry, the capital of {country} is {capital}.")
play_again = input("Do you want to play again? (yes/no) ")
if play_again.lower() != "yes":
break
if __name__ == "__main__":
main()
# In[ ]: