Hi...
This is the code to make tests... in this case tests about capitals of USA.
I have been inspired by this guy
https://automatetheboringstuff.com/chapter8/
But the code is different from what he did... I don't write in an external file the test, but you can copy the output. Maybe I will post the version to create txt files with this test.
from random import shuffle
capitals = {'Alabama': 'Montgomery',
'Alaska': 'Juneau',
'Arizona': 'Phoenix',
'Arkansas': 'Little Rock',
'California': 'Sacramento',
'Colorado': 'Denver',
'Connecticut': 'Hartford',
'Delaware': 'Dover',
'Florida': 'Tallahassee',
'Georgia': 'Atlanta',
'Hawaii': 'Honolulu',
'Idaho': 'Boise',
'Illinois': 'Springfield',
'Indiana': 'Indianapolis',
'Iowa': 'Des Moines',
'Kansas': 'Topeka',
'Kentucky': 'Frankfort',
'Louisiana': 'Baton Rouge',
'Maine': 'Augusta',
'Maryland': 'Annapolis',
'Massachusetts': 'Boston',
'Michigan': 'Lansing',
'Minnesota': 'Saint Paul',
'Mississippi': 'Jackson',
'Missouri': 'Jefferson City',
'Montana': 'Helena',
'Nebraska': 'Lincoln',
'Nevada': 'Carson City',
'New Hampshire': 'Concord',
'New Jersey': 'Trenton',
'New Mexico': 'Santa Fe',
'New York': 'Albany',
'North Carolina': 'Raleigh',
'North Dakota': 'Bismarck',
'Ohio': 'Columbus',
'Oklahoma': 'Oklahoma City',
'Oregon': 'Salem',
'Pennsylvania': 'Harrisburg',
'Rhode Island': 'Providence',
'South Carolina': 'Columbia',
'South Dakota': 'Pierre',
'Tennessee': 'Nashville',
'Texas': 'Austin',
'Utah': 'Salt Lake City',
'Vermont': 'Montpelier',
'Virginia': 'Richmond',
'Washington': 'Olympia',
'West Virginia': 'Charleston',
'Wisconsin': 'Madison',
'Wyoming': 'Cheyenne'}
print("Do you know the capitals of USA?")
states = []
for state in capitals:
states += [state]
shuffle(states)
answers = [capitals[i] for i in states]
for n in range(30):
if states[n][0] in "H":
article = "of the"
else:
article = "of"
print("Which is the capital",article, states[n], "?")
right = answers[n]
r_copy = answers.copy()
r_copy.pop(n)
shuffle(r_copy)
ris = []
for i in range(3):
ris += [r_copy[i]]
ris += [right]
shuffle(ris)
for i in range(4):
print(" - ",ris[i])
print("Solution:",right)
See ya soon
Comments
Post a Comment