-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwheather forecast.list.py
More file actions
53 lines (26 loc) · 993 Bytes
/
wheather forecast.list.py
File metadata and controls
53 lines (26 loc) · 993 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
temp_data = []
n = int(input("How many days of data do you want to enter? "))
for i in range(n):
temp = float(input(f"Enter the temperature for day {i+1}: "))
temp_data.append(temp)
print(f"The temperature data is: {temp_data}")
def max_index(lst):
max_elem = lst[0]
max_idx = 0
for i in range(1, len(lst)):
if lst[i] > max_elem:
max_elem = lst[i]
max_idx = i
return max_idx
def min_index(lst):
min_elem = lst[0]
min_idx = 0
for i in range(1, len(lst)):
if lst[i] < min_elem:
min_elem = lst[i]
min_idx = i
return min_idx
warmest_day = max_index(temp_data) + 1
coldest_day = min_index(temp_data) + 1
print(f"The warmest day is day {warmest_day} with a temperature of {temp_data[warmest_day-1]} degrees.")
print(f"The coldest day is day {coldest_day} with a temperature of {temp_data[coldest_day-1]} degrees.")