Compare commits
3 Commits
59a3d6d830
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ce3befd167 | |||
| 612ad7c549 | |||
| c34b9d4c52 |
7
024/input/letters/starting_letter.txt
Normal file
7
024/input/letters/starting_letter.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear [name],
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
8
024/input/names/invited_names.txt
Normal file
8
024/input/names/invited_names.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Aang
|
||||||
|
Zuko
|
||||||
|
Appa
|
||||||
|
Katara
|
||||||
|
Sokka
|
||||||
|
Momo
|
||||||
|
Uncle Iroh
|
||||||
|
Toph
|
||||||
20
024/main.py
Normal file
20
024/main.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#TODO: Create a letter using starting_letter.txt
|
||||||
|
#for each name in invited_names.txt
|
||||||
|
#Replace the [name] placeholder with the actual name.
|
||||||
|
#Save the letters in the folder "ReadyToSend".
|
||||||
|
|
||||||
|
#Hint1: This method will help you: https://www.w3schools.com/python/ref_file_readlines.asp
|
||||||
|
#Hint2: This method will also help you: https://www.w3schools.com/python/ref_string_replace.asp
|
||||||
|
#Hint3: THis method will help you: https://www.w3schools.com/python/ref_string_strip.asp
|
||||||
|
|
||||||
|
|
||||||
|
with open("input/names/invited_names.txt") as n:
|
||||||
|
for name in n.readlines():
|
||||||
|
name = name.strip()
|
||||||
|
output_letter = ""
|
||||||
|
with open("input/letters/starting_letter.txt") as l:
|
||||||
|
for letter_line in l:
|
||||||
|
output_letter += letter_line.replace("[name]", name)
|
||||||
|
|
||||||
|
with open(f"output/ready_to_send/to_{name}.txt", "w") as final:
|
||||||
|
final.write(output_letter)
|
||||||
7
024/output/ready_to_send/example.txt
Normal file
7
024/output/ready_to_send/example.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Aang,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Aang.txt
Normal file
7
024/output/ready_to_send/to_Aang.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Aang,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Appa.txt
Normal file
7
024/output/ready_to_send/to_Appa.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Appa,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Katara.txt
Normal file
7
024/output/ready_to_send/to_Katara.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Katara,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Momo.txt
Normal file
7
024/output/ready_to_send/to_Momo.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Momo,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Sokka.txt
Normal file
7
024/output/ready_to_send/to_Sokka.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Sokka,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Toph.txt
Normal file
7
024/output/ready_to_send/to_Toph.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Toph,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Uncle Iroh.txt
Normal file
7
024/output/ready_to_send/to_Uncle Iroh.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Uncle Iroh,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
7
024/output/ready_to_send/to_Zuko.txt
Normal file
7
024/output/ready_to_send/to_Zuko.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Dear Zuko,
|
||||||
|
|
||||||
|
You are invited to my birthday this Saturday.
|
||||||
|
|
||||||
|
Hope you can make it!
|
||||||
|
|
||||||
|
Angela
|
||||||
51
025/50_states.csv
Normal file
51
025/50_states.csv
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
state,x,y
|
||||||
|
Alabama,139,-77
|
||||||
|
Alaska,-204,-170
|
||||||
|
Arizona,-203,-40
|
||||||
|
Arkansas,57,-53
|
||||||
|
California,-297,13
|
||||||
|
Colorado,-112,20
|
||||||
|
Connecticut,297,96
|
||||||
|
Delaware,275,42
|
||||||
|
Florida,220,-145
|
||||||
|
Georgia,182,-75
|
||||||
|
Hawaii,-317,-143
|
||||||
|
Idaho,-216,122
|
||||||
|
Illinois,95,37
|
||||||
|
Indiana,133,39
|
||||||
|
Iowa,38,65
|
||||||
|
Kansas,-17,5
|
||||||
|
Kentucky,149,1
|
||||||
|
Louisiana,59,-114
|
||||||
|
Maine,319,164
|
||||||
|
Maryland,288,27
|
||||||
|
Massachusetts,312,112
|
||||||
|
Michigan,148,101
|
||||||
|
Minnesota,23,135
|
||||||
|
Mississippi,94,-78
|
||||||
|
Missouri,49,6
|
||||||
|
Montana,-141,150
|
||||||
|
Nebraska,-61,66
|
||||||
|
Nevada,-257,56
|
||||||
|
New Hampshire,302,127
|
||||||
|
New Jersey,282,65
|
||||||
|
New Mexico,-128,-43
|
||||||
|
New York,236,104
|
||||||
|
North Carolina,239,-22
|
||||||
|
North Dakota,-44,158
|
||||||
|
Ohio,176,52
|
||||||
|
Oklahoma,-8,-41
|
||||||
|
Oregon,-278,138
|
||||||
|
Pennsylvania,238,72
|
||||||
|
Rhode Island,318,94
|
||||||
|
South Carolina,218,-51
|
||||||
|
South Dakota,-44,109
|
||||||
|
Tennessee,131,-34
|
||||||
|
Texas,-38,-106
|
||||||
|
Utah,-189,34
|
||||||
|
Vermont,282,154
|
||||||
|
Virginia,234,12
|
||||||
|
Washington,-257,193
|
||||||
|
West Virginia,200,20
|
||||||
|
Wisconsin,83,113
|
||||||
|
Wyoming,-134,90
|
||||||
|
BIN
025/blank_states_img.gif
Normal file
BIN
025/blank_states_img.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
52
025/main.py
Normal file
52
025/main.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
from turtle import Turtle, Screen
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
FONT = ("Courier", 14, "normal")
|
||||||
|
|
||||||
|
screen = Screen()
|
||||||
|
screen.setup(725,491)
|
||||||
|
screen.bgpic('blank_states_img.gif')
|
||||||
|
screen.tracer(0)
|
||||||
|
|
||||||
|
data = pd.read_csv("50_states.csv")
|
||||||
|
# state, x, y
|
||||||
|
|
||||||
|
game_on = True
|
||||||
|
states_remaining = len(data)
|
||||||
|
found_states = []
|
||||||
|
|
||||||
|
while len(found_states) < 50:
|
||||||
|
guess = str(screen.textinput(f"{states_remaining} states to find", "Find a state:"))
|
||||||
|
if guess == "None":
|
||||||
|
missing_states = [ s for s in data.states if s not in found_states ]
|
||||||
|
output = pd.DataFrame(missing_states)
|
||||||
|
output.to_csv("missing_states.csv")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
state = data[data.state == guess.title()]
|
||||||
|
|
||||||
|
# if the subset is not empty, it means the state is in the list
|
||||||
|
if len(state) > 0:
|
||||||
|
|
||||||
|
|
||||||
|
x_pos = state.x.item() #state.iloc[0]["x"]
|
||||||
|
y_pos = state.y.item() #state.iloc[0]["y"]
|
||||||
|
state_name = state.iloc[0]["state"]
|
||||||
|
|
||||||
|
if state_name in found_states:
|
||||||
|
continue
|
||||||
|
|
||||||
|
states_remaining -= 1
|
||||||
|
|
||||||
|
found_states.append(state_name)
|
||||||
|
text = Turtle()
|
||||||
|
text.pu()
|
||||||
|
text.color("black")
|
||||||
|
text.hideturtle()
|
||||||
|
text.goto(x_pos, y_pos)
|
||||||
|
text.write(state_name, align="center", font=FONT)
|
||||||
|
screen.update()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
screen.mainloop()
|
||||||
48
025/missing_states.csv
Normal file
48
025/missing_states.csv
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
Alabama
|
||||||
|
Alaska
|
||||||
|
Arkansas
|
||||||
|
California
|
||||||
|
Colorado
|
||||||
|
Connecticut
|
||||||
|
Delaware
|
||||||
|
Florida
|
||||||
|
Georgia
|
||||||
|
Hawaii
|
||||||
|
Idaho
|
||||||
|
Illinois
|
||||||
|
Indiana
|
||||||
|
Iowa
|
||||||
|
Kansas
|
||||||
|
Kentucky
|
||||||
|
Louisiana
|
||||||
|
Maine
|
||||||
|
Maryland
|
||||||
|
Massachusetts
|
||||||
|
Michigan
|
||||||
|
Minnesota
|
||||||
|
Mississippi
|
||||||
|
Missouri
|
||||||
|
Montana
|
||||||
|
Nebraska
|
||||||
|
Nevada
|
||||||
|
New Hampshire
|
||||||
|
New Jersey
|
||||||
|
New Mexico
|
||||||
|
New York
|
||||||
|
North Carolina
|
||||||
|
North Dakota
|
||||||
|
Oklahoma
|
||||||
|
Oregon
|
||||||
|
Pennsylvania
|
||||||
|
Rhode Island
|
||||||
|
South Carolina
|
||||||
|
South Dakota
|
||||||
|
Tennessee
|
||||||
|
Texas
|
||||||
|
Utah
|
||||||
|
Vermont
|
||||||
|
Virginia
|
||||||
|
Washington
|
||||||
|
West Virginia
|
||||||
|
Wisconsin
|
||||||
|
Wyoming
|
||||||
|
3024
025/squirrels.csv
Normal file
3024
025/squirrels.csv
Normal file
File diff suppressed because it is too large
Load Diff
54
025/task.py
Normal file
54
025/task.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# data = []
|
||||||
|
# with open("weather_data.csv") as f:
|
||||||
|
# for line in f.readlines():
|
||||||
|
# data.append(line.strip().split(','))
|
||||||
|
|
||||||
|
# print(data)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
# import csv
|
||||||
|
|
||||||
|
# temperatures = []
|
||||||
|
# with open("weather_data.csv") as f:
|
||||||
|
# reader = csv.reader(f)
|
||||||
|
# next(reader)
|
||||||
|
|
||||||
|
# for row in reader:
|
||||||
|
# temperatures.append(int(row[1]))
|
||||||
|
|
||||||
|
# print(temperatures)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# import pandas as pd
|
||||||
|
|
||||||
|
# data = pd.read_csv("weather_data.csv", delimiter=",")
|
||||||
|
# print(data["temp"].mean())
|
||||||
|
# print(data["temp"].max())
|
||||||
|
|
||||||
|
# output = data[data.temp == data.temp.max()]
|
||||||
|
# print(output)
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
data = pd.read_csv("squirrels.csv")
|
||||||
|
|
||||||
|
colors = data["Primary Fur Color"].unique()
|
||||||
|
|
||||||
|
output_colors = []
|
||||||
|
output_count = []
|
||||||
|
for color in colors:
|
||||||
|
if type(color) != str:
|
||||||
|
continue
|
||||||
|
count = len(data[data["Primary Fur Color"] == color])
|
||||||
|
|
||||||
|
output_colors.append(color)
|
||||||
|
output_count.append(count)
|
||||||
|
|
||||||
|
output = {"color": output_colors, "count": output_count}
|
||||||
|
|
||||||
|
df = pd.DataFrame(output)
|
||||||
|
|
||||||
|
print(df.to_csv(index=False))
|
||||||
8
025/weather_data.csv
Normal file
8
025/weather_data.csv
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
day,temp,condition
|
||||||
|
Monday,12,Sunny
|
||||||
|
Tuesday,14,Rain
|
||||||
|
Wednesday,15,Rain
|
||||||
|
Thursday,14,Cloudy
|
||||||
|
Friday,21,Sunny
|
||||||
|
Saturday,22,Sunny
|
||||||
|
Sunday,24,Sunny
|
||||||
|
15
026/main.py
Normal file
15
026/main.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
# Keyword Method with iterrows()
|
||||||
|
# {new_key:new_value for (index, row) in df.iterrows()}
|
||||||
|
|
||||||
|
#TODO 1. Create a dictionary in this format:
|
||||||
|
# {"A": "Alfa", "B": "Bravo"}
|
||||||
|
|
||||||
|
data = pd.read_csv("nato_phonetic_alphabet.csv")
|
||||||
|
dict = { row.letter:row.code for (index, row) in data.iterrows() }
|
||||||
|
|
||||||
|
#TODO 2. Create a list of the phonetic code words from a word that the user inputs.
|
||||||
|
|
||||||
|
input = list(input("Which word do you want to spell?\n"))
|
||||||
|
print([ dict[letter.upper()] for letter in input])
|
||||||
27
026/nato_phonetic_alphabet.csv
Normal file
27
026/nato_phonetic_alphabet.csv
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
letter,code
|
||||||
|
A,Alfa
|
||||||
|
B,Bravo
|
||||||
|
C,Charlie
|
||||||
|
D,Delta
|
||||||
|
E,Echo
|
||||||
|
F,Foxtrot
|
||||||
|
G,Golf
|
||||||
|
H,Hotel
|
||||||
|
I,India
|
||||||
|
J,Juliet
|
||||||
|
K,Kilo
|
||||||
|
L,Lima
|
||||||
|
M,Mike
|
||||||
|
N,November
|
||||||
|
O,Oscar
|
||||||
|
P,Papa
|
||||||
|
Q,Quebec
|
||||||
|
R,Romeo
|
||||||
|
S,Sierra
|
||||||
|
T,Tango
|
||||||
|
U,Uniform
|
||||||
|
V,Victor
|
||||||
|
W,Whiskey
|
||||||
|
X,X-ray
|
||||||
|
Y,Yankee
|
||||||
|
Z,Zulu
|
||||||
|
5
026/task.py
Normal file
5
026/task.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||||
|
|
||||||
|
new_numbers = [ n for n in numbers if n % 2 == 1 ]
|
||||||
|
|
||||||
|
print(new_numbers)
|
||||||
Reference in New Issue
Block a user