-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (34 loc) · 1.26 KB
/
main.py
File metadata and controls
40 lines (34 loc) · 1.26 KB
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
import turtle
import pandas
screen = turtle.Screen()
screen.title("U.S. States Game")
image = "blank_states_img.gif"
screen.addshape(image)
turtle.shape(image)
tim = turtle.Turtle()
tim.hideturtle()
tim.speed("fastest")
states = pandas.read_csv("50_states.csv")
states_list = states.state.to_list()
x_coor_list = states.x.to_list()
y_coor_list = states.y.to_list()
guessed_states = []
while len(guessed_states) < 50:
answer = screen.textinput(title=f"{len(guessed_states)}/{len(states_list)} States Correct",
prompt="What's another state's name?").title()
if answer == "Exit":
unguessed_states = [item for item in states_list if item not in guessed_states]
new_data = pandas.DataFrame(unguessed_states)
new_data.to_csv("state_to_learn.csv")
break
if answer in states_list:
guessed_states.append(answer)
ans_x_coor = x_coor_list[states_list.index(answer)]
ans_y_cor = y_coor_list[states_list.index(answer)]
tim.penup()
tim.goto(ans_x_coor, ans_y_cor)
tim.write(arg=f"{answer}", font=("Courier", 8, "bold"))
# def get_mouse_click_coor(x, y):
# print(x, y)
# turtle.onscreenclick(get_mouse_click_coor)
# turtle.mainloop()