Skip to content

Commit c49d589

Browse files
committed
day26
1 parent f298263 commit c49d589

File tree

5 files changed

+107
-32
lines changed

5 files changed

+107
-32
lines changed

day26/main.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
student_dict = {
2+
"student": ["Angela", "James", "Lily"],
3+
"score": [56, 76, 98]
4+
}
5+
6+
# Looping through dictionaries:
7+
# for (key, value) in student_dict.items():
8+
# # Access key and value
9+
# pass
10+
11+
# student_data_frame = pandas.DataFrame(student_dict)
12+
13+
# Loop through rows of a data frame
14+
# for (index, row) in student_data_frame.iterrows():
15+
# # Access index and row
16+
# # Access row.student or row.score
17+
# pass
18+
19+
# Keyword Method with iterrows()
20+
# {new_key:new_value for (index, row) in df.iterrows()}
21+
22+
# TODO 1. Create a dictionary in this format:
23+
{"A": "Alfa", "B": "Bravo"}
24+
25+
# TODO 2. Create a list of the phonetic code words from a word that the user inputs.
26+
27+
import pandas
28+
29+
nato_source = pandas.read_csv("nato_phonetic_alphabet.csv")
30+
31+
def gen_nato():
32+
nato = {row.letter: row.code for (index, row) in nato_source.iterrows()}
33+
return nato
34+
35+
36+
def get_nato(nato_alpha, letter):
37+
if letter != " ":
38+
return nato_alpha[letter.upper()]
39+
else:
40+
return " "
41+
42+
43+
def take_input():
44+
word = input("Enter a word to present as NATO alphabet: ")
45+
return word
46+
47+
48+
def main():
49+
nato = gen_nato()
50+
word = take_input()
51+
final = [get_nato(nato, letter) for letter in word]
52+
print(final)
53+
54+
55+
if __name__ == "__main__":
56+
main()

day26/nato_phonetic_alphabet.csv

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
letter,code
2+
A,Alfa
3+
B,Bravo
4+
C,Charlie
5+
D,Delta
6+
E,Echo
7+
F,Foxtrot
8+
G,Golf
9+
H,Hotel
10+
I,India
11+
J,Juliet
12+
K,Kilo
13+
L,Lima
14+
M,Mike
15+
N,November
16+
O,Oscar
17+
P,Papa
18+
Q,Quebec
19+
R,Romeo
20+
S,Sierra
21+
T,Tango
22+
U,Uniform
23+
V,Victor
24+
W,Whiskey
25+
X,X-ray
26+
Y,Yankee
27+
Z,Zulu

day26/scratch.py

Whitespace-only changes.

states_game/learning.csv

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
1,Alaska
44
2,Arizona
55
3,Arkansas
6-
4,California
7-
5,Colorado
8-
6,Connecticut
9-
7,Delaware
10-
8,Florida
11-
9,Georgia
6+
4,Colorado
7+
5,Connecticut
8+
6,Delaware
9+
7,Florida
10+
8,Georgia
11+
9,Hawaii
1212
10,Idaho
1313
11,Illinois
1414
12,Indiana
@@ -25,25 +25,20 @@
2525
23,Missouri
2626
24,Montana
2727
25,Nebraska
28-
26,Nevada
29-
27,New Hampshire
30-
28,New Jersey
31-
29,New Mexico
32-
30,New York
33-
31,North Carolina
34-
32,North Dakota
35-
33,Oklahoma
36-
34,Oregon
37-
35,Pennsylvania
38-
36,Rhode Island
39-
37,South Carolina
40-
38,South Dakota
41-
39,Tennessee
42-
40,Texas
43-
41,Utah
44-
42,Vermont
45-
43,Virginia
46-
44,Washington
47-
45,West Virginia
48-
46,Wisconsin
49-
47,Wyoming
28+
26,New Hampshire
29+
27,New Jersey
30+
28,New York
31+
29,North Carolina
32+
30,North Dakota
33+
31,Oklahoma
34+
32,Pennsylvania
35+
33,Rhode Island
36+
34,South Carolina
37+
35,South Dakota
38+
36,Tennessee
39+
37,Utah
40+
38,Vermont
41+
39,Virginia
42+
40,West Virginia
43+
41,Wisconsin
44+
42,Wyoming

states_game/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919

2020
def cleanup():
21-
all_states = state_data.state.to_list()
22-
for state in all_states:
23-
if state in guessed:
24-
all_states.remove(state)
21+
all_states = [state for state in state_data.state.to_list() if state not in guessed]
2522
data = {"state": all_states}
2623
pandas.DataFrame(data=data).to_csv("learning.csv")
2724

0 commit comments

Comments
 (0)