File tree Expand file tree Collapse file tree 5 files changed +130
-0
lines changed
GAMES/Guess the US States Expand file tree Collapse file tree 5 files changed +130
-0
lines changed Original file line number Diff line number Diff line change
1
+ state,x,y
2
+ Alabama,139,-77
3
+ Alaska,-204,-170
4
+ Arizona,-203,-40
5
+ Arkansas,57,-53
6
+ California,-297,13
7
+ Colorado,-112,20
8
+ Connecticut,297,96
9
+ Delaware,275,42
10
+ Florida,220,-145
11
+ Georgia,182,-75
12
+ Hawaii,-317,-143
13
+ Idaho,-216,122
14
+ Illinois,95,37
15
+ Indiana,133,39
16
+ Iowa,38,65
17
+ Kansas,-17,5
18
+ Kentucky,149,1
19
+ Louisiana,59,-114
20
+ Maine,319,164
21
+ Maryland,288,27
22
+ Massachusetts,312,112
23
+ Michigan,148,101
24
+ Minnesota,23,135
25
+ Mississippi,94,-78
26
+ Missouri,49,6
27
+ Montana,-141,150
28
+ Nebraska,-61,66
29
+ Nevada,-257,56
30
+ New Hampshire,302,127
31
+ New Jersey,282,65
32
+ New Mexico,-128,-43
33
+ New York,236,104
34
+ North Carolina,239,-22
35
+ North Dakota,-44,158
36
+ Ohio,176,52
37
+ Oklahoma,-8,-41
38
+ Oregon,-278,138
39
+ Pennsylvania,238,72
40
+ Rhode Island,318,94
41
+ South Carolina,218,-51
42
+ South Dakota,-44,109
43
+ Tennessee,131,-34
44
+ Texas,-38,-106
45
+ Utah,-189,34
46
+ Vermont,282,154
47
+ Virginia,234,12
48
+ Washington,-257,193
49
+ West Virginia,200,20
50
+ Wisconsin,83,113
51
+ Wyoming,-134,90
Original file line number Diff line number Diff line change
1
+
2
+ # US States Game
3
+
4
+
5
+ #### This is a trivia game that uses the turtle module.<br >Can you guess all 50 states of the US?
6
+
7
+
8
+
9
+ ## Requirements
10
+ - Pandas
11
+ - Turtle
12
+
13
+
14
+ ### To install pandas:
15
+
16
+ ```
17
+ pip install pandas
18
+ ```
19
+ ### How to run the file
20
+
21
+ open the terminal and navigate to the path of the file
22
+ ```
23
+ python main.py
24
+
25
+ ```
26
+ ### Sample Output
27
+
28
+ ![ Sample Output] ( https://github.com/sahil-s-246/Python-project-Scripts/blob/sahil-s-246-patch-1/GAMES/Guess%20the%20US%20States/Sample_Output.png )
Original file line number Diff line number Diff line change
1
+ import turtle
2
+ import pandas
3
+
4
+
5
+ df = pandas .read_csv ("50_states.csv" )
6
+ screen = turtle .Screen ()
7
+ screen .title ("U.S. States Game" )
8
+ img_gif = "blank_states_img.gif"
9
+ screen .addshape (img_gif )
10
+ # register the shape
11
+ turtle .shape (img_gif )
12
+ state_list = df .state .to_list ()
13
+ guessed_states = []
14
+
15
+
16
+ def reveal_state (x , y ):
17
+ name = turtle .Turtle ()
18
+ name .hideturtle ()
19
+ name .penup ()
20
+ name .goto (x , y )
21
+ name .write (f"{ ans } " )
22
+
23
+
24
+ while len (guessed_states ) < 50 :
25
+ ans = screen .textinput (title = f" Score: { len (guessed_states )} /50" , prompt = "Name a State: " ).title ()
26
+
27
+ if ans == "exit" .title ():
28
+ correction = [state for state in state_list if state not in guessed_states ]
29
+
30
+ ans_file = pandas .DataFrame (correction )
31
+ ans_file .to_csv ("correct_ans." )
32
+ break
33
+
34
+ # ALl the states you have missed will be written in the correct_ans.csv file
35
+
36
+ if ans in state_list :
37
+ guessed_states .append (ans )
38
+ state_data = df [df .state == ans ]
39
+ x_cor = state_data .x
40
+ y_cor = state_data .y
41
+ reveal_state (int (x_cor ), int (y_cor ))
42
+
43
+
44
+ # def get_mouse_click_coordinate(x, y):
45
+ # print(x, y)
46
+
47
+ # turtle.onscreenclick(get_mouse_click_coordinate)
48
+ # Get turtle coordinates on image
49
+ # These co ordinates were inserted in 50_states.csv
50
+
51
+ screen .exitonclick ()
You can’t perform that action at this time.
0 commit comments