forked from dominict/pythonteachingcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2M4[Omar][Idris].py
More file actions
31 lines (20 loc) · 802 Bytes
/
P2M4[Omar][Idris].py
File metadata and controls
31 lines (20 loc) · 802 Bytes
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
# import the file
import os
cmd = "curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/world_temp_mean.csv -o mean_temp.txt"
os.system(cmd)
# open in append plus mode and add Rio de Janeiro
mean_temp_file = open('mean_temp.txt', 'a+')
mean_temp_file.write("Rio de Janeiro,Brazil,30.0,18.0\n")
# seek to beginning and read headings
mean_temp_file.seek(0)
headings = mean_temp_file.readline()
headings = headings.split(',')
# print your name
print("Omar Idris")
# while loop to print city and highest monthly average temp
city_temp = mean_temp_file.readline()
while city_temp:
city_temp = city_temp.split(',')
print("City of", city_temp[0], "month ave: highest high is", city_temp[2], "Celsius")
city_temp = mean_temp_file.readline()
mean_temp_file.close()