Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c82a7b3

Browse files
author
SamLaFell
committed
Class_Assignments
1 parent c39c494 commit c82a7b3

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

‎.DS_Store

2 KB
Binary file not shown.

‎Python_Class/sam_lafell_dark_sky.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
# In[ ]:
5+
6+
7+
import os
8+
import pandas as pd
9+
import numpy as np
10+
11+
os.chdir('/Users/samlafell/Desktop/MSA/Python/Healy_Class')
12+
print(os.getcwd())
13+
14+
from forecastiopy import *
15+
16+
api_key = 'c14295d6060f09271a3d29d107f614b2'
17+
18+
loc = [["Anchorage, Alaska", 61.2181, -149.9003],
19+
["Buenos Aires, Argentina", -34.6037, -58.3816],
20+
["Sao Jose dos Campos, Brazil", -23.2237, -45.9009],
21+
['San Jose, Costa Rica', 9.9281, -84.0907],
22+
['Nanaimo, Canada', 49.1659, -123.9401],
23+
['Ningbo, China', 29.8683, 121.5440],
24+
['Giza, Egypt', 30.0131, 31.2089],
25+
['Mannheim, Germany', 49.4875, 8.4660],
26+
['Hyderabad, India', 17.3850, 78.4867],
27+
['Tehran, Iran', 35.6892, 51.3890],
28+
['Bishkek, Kyrgyzstan', 42.8746, 74.5698],
29+
['Riga, Latvia', 56.9496, 24.1052],
30+
['Quetta, Pakistan', 30.1798, 66.9750],
31+
['Warsaw, Poland', 52.2297, 21.0122],
32+
['Dhahran, Saudi Arabia', 26.2361, 50.0393],
33+
["Madrid, Spain", 40.4168, -3.7038],
34+
["Oldham, United Kingdom", 53.5409, -2.1114]]
35+
36+
whole_list = []
37+
new_list = []
38+
for i in loc:
39+
max = []
40+
min = []
41+
city = i[0]
42+
latitude = i[1]
43+
longitude = i[2]
44+
weather = ForecastIO.ForecastIO(api_key, latitude=latitude, longitude=longitude, units=ForecastIO.ForecastIO.UNITS_SI)
45+
daily = FIODaily.FIODaily(weather)
46+
for day in range(2, 7):
47+
val = daily.get(day)
48+
min.append(val['temperatureMin'])
49+
max.append(val['temperatureMax'])
50+
max_mean = round((sum(max) / 5), 2)
51+
min_mean = round((sum(min) / 5), 2)
52+
max.append(max_mean)
53+
min.append(min_mean)
54+
whole_list = [city, min[0], max[0], min[1], max[1], min[2], max[2], min[3], max[3], min[4], max[4], min[5], max[5]]
55+
new_list.append(whole_list)
56+
57+
dark_sky_api = pd.DataFrame(new_list, columns=['City', 'Min 1', 'Max 1', 'Min 2', 'Max 2',
58+
'Min 3', 'Max 3', 'Min 4', 'Max 4', 'Min 5', 'Max 5', 'Min Avg', 'Max Avg'])
59+
60+
dark_sky_api.set_index('City', inplace=True)
61+
62+
dark_sky_api.to_csv('lafell_dark_sky_api.csv')
63+

‎Python_Class/tic_tac_toe.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
tic_tac_toe = {'A1': ' ', 'B1': ' ', 'C1': ' ', 'A2': ' ', 'B2': ' ', 'C2': ' ',
2+
'A3': ' ', 'B3': ' ', 'C3': ' '}
3+
4+
while True:
5+
print('Welcome to Tic-Tac-Toe! Player 1, please enter your name. (blank to quit)')
6+
player1name = input()
7+
if player1name == '':
8+
break
9+
print('Welcome, ' + player1name + '. You will be X')
10+
print('Player 2, please enter your name')
11+
player2name = input()
12+
print('Welcome, ' + player2name + '. You will be O')
13+
break
14+
15+
16+
def board(board):
17+
print(tic_tac_toe['A1'] + '|' + tic_tac_toe['B1'] + '|' + tic_tac_toe['C1'])
18+
print('------')
19+
print(tic_tac_toe['A2'] + '|' + tic_tac_toe['B2'] + '|' + tic_tac_toe['C2'])
20+
print('------')
21+
print(tic_tac_toe['A3'] + '|' + tic_tac_toe['B3'] + '|' + tic_tac_toe['C3'])
22+
23+
24+
def win_check(tic_tac_toe):
25+
if tic_tac_toe['A1'] == 'X' and tic_tac_toe['A2'] == 'X' and tic_tac_toe['A3'] == 'X':
26+
global win
27+
win = 1
28+
return print(player1name, 'wins!')
29+
elif tic_tac_toe['B1'] == 'X' and tic_tac_toe['B2'] == 'X' and tic_tac_toe['B3'] == 'X':
30+
win = 1
31+
return print(player1name, 'wins!')
32+
elif tic_tac_toe['C1'] == 'X' and tic_tac_toe['C2'] == 'X' and tic_tac_toe['C3'] == 'X':
33+
win = 1
34+
return print(player1name, 'wins!')
35+
elif tic_tac_toe['A1'] == 'X' and tic_tac_toe['B2'] == 'X' and tic_tac_toe['C3'] == 'X':
36+
win = 1
37+
return print(player1name, 'wins!')
38+
elif tic_tac_toe['A1'] == 'X' and tic_tac_toe['B1'] == 'X' and tic_tac_toe['C1'] == 'X':
39+
win = 1
40+
return print(player1name, 'wins!')
41+
elif tic_tac_toe['A1'] == 'X' and tic_tac_toe['B1'] == 'X' and tic_tac_toe['C1'] == 'X':
42+
win = 1
43+
return print(player1name, 'wins!')
44+
elif tic_tac_toe['A2'] == 'X' and tic_tac_toe['B2'] == 'X' and tic_tac_toe['C2'] == 'X':
45+
win = 1
46+
return print(player1name, 'wins!')
47+
elif tic_tac_toe['A3'] == 'X' and tic_tac_toe['B3'] == 'X' and tic_tac_toe['C3'] == 'X':
48+
win = 1
49+
return print(player1name, 'wins!')
50+
elif tic_tac_toe['A3'] == 'X' and tic_tac_toe['B2'] == 'X' and tic_tac_toe['C1'] == 'X':
51+
win = 1
52+
return print(player1name, 'wins!')
53+
elif tic_tac_toe['A1'] == 'O' and tic_tac_toe['A2'] == 'O' and tic_tac_toe['A3'] == 'O':
54+
win = 1
55+
return print(player2name, 'wins!')
56+
elif tic_tac_toe['B1'] == 'O' and tic_tac_toe['B2'] == 'O' and tic_tac_toe['B3'] == 'O':
57+
win = 1
58+
return print(player2name, 'wins!')
59+
elif tic_tac_toe['C1'] == 'O' and tic_tac_toe['C2'] == 'O' and tic_tac_toe['C3'] == 'O':
60+
win = 1
61+
return print(player2name, 'wins!')
62+
elif tic_tac_toe['A1'] == 'O' and tic_tac_toe['B2'] == 'O' and tic_tac_toe['C3'] == 'O':
63+
win = 1
64+
return print(player2name, 'wins!')
65+
elif tic_tac_toe['A1'] == 'O' and tic_tac_toe['B1'] == 'O' and tic_tac_toe['C1'] == 'O':
66+
win = 1
67+
return print(player2name, 'wins!')
68+
elif tic_tac_toe['A2'] == 'O' and tic_tac_toe['B2'] == 'O' and tic_tac_toe['C2'] == 'O':
69+
win = 1
70+
return print(player2name, 'wins!')
71+
elif tic_tac_toe['A3'] == 'O' and tic_tac_toe['B3'] == 'O' and tic_tac_toe['C3'] == 'O':
72+
win = 1
73+
return print(player2name, 'wins!')
74+
elif tic_tac_toe['A3'] == 'O' and tic_tac_toe['B2'] == 'O' and tic_tac_toe['C1'] == 'O':
75+
win = 1
76+
return print(player2name, 'wins!')
77+
78+
79+
board(board)
80+
81+
turn = 'X'
82+
win = 0
83+
for num in range(9):
84+
if win:
85+
break
86+
print('Turn for ', turn + '. Which space would you like?' +
87+
' Type A1 for top-left and C3 for bottom-right.')
88+
move = input()
89+
while move not in tic_tac_toe.keys():
90+
print('I did not get that. Could you enter a valid value between A1 and C3.')
91+
move = input()
92+
while tic_tac_toe[move] != ' ':
93+
print('Try a space that has not been taken.')
94+
board(board)
95+
move = input()
96+
tic_tac_toe[move] = turn
97+
if turn == 'X':
98+
turn = 'O'
99+
else:
100+
turn = 'X'
101+
board(board)
102+
if win_check(tic_tac_toe):
103+
break
104+
105+
if not win:
106+
print('It was a tie!')

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /