-
Notifications
You must be signed in to change notification settings - Fork 18
/
02_files_and_weather_lab.py
97 lines (68 loc) · 1.82 KB
/
02_files_and_weather_lab.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'''
Lab: Reading and Writing Files in Python
'''
'''
PART 1:
Read in drinks.csv
Store the header in a list called 'header'
Store the data in a list of lists called 'data'
Hint: you've already seen this code!
'''
'''
PART 2:
Isolate the beer_servings column in a list of integers called 'beers'
Hint: you can use a list comprehension to do this in one line
Expected output:
beers == [0, 89, ..., 32, 64]
len(beers) == 193
'''
'''
PART 3:
Create separate lists of NA and EU beer servings: 'NA_beers', 'EU_beers'
Hint: you can use a list comprehension with a condition
Expected output:
NA_beers == [102, 122, ..., 197, 249]
len(NA_beers) == 23
EU_beers == [89, 245, ..., 206, 219]
len(EU_beers) == 45
'''
'''
PART 4:
Calculate the average NA and EU beer servings to 2 decimals: 'NA_avg', 'EU_avg'
Hint: don't forget about data types!
Expected output:
NA_avg == 145.43
EU_avg == 193.78
'''
'''
PART 5:
Write a CSV file called 'avg_beer.csv' with two columns and three rows.
The first row is the column headers: 'continent', 'avg_beer'
The second and third rows contain the NA and EU values.
Hint: think about what data structure will make this easy
Expected output (in the actual file):
continent,avg_beer
NA,145.43
EU,193.78
'''
'''
Part 6:
Use the requests module to pull in weather data for any city
Hint: you can use Istanbul from the other code file but you can search
for cities at http://openweathermap.org/find
Create a dates list that stores the date of each datapoint as well as
temperature and humidity
You've already seen this code!
'''
'''
Part 7
Create a list of the pressure measurements and plot it against dates
'''
'''
Part 8
Make a scatter plot plotting pressure against temperature and humidity
'''
'''
BONUS:
Learn csv.DictReader() and use it to redo Parts 1, 2, and 3.
'''