-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTASK3.py
More file actions
58 lines (52 loc) · 2.28 KB
/
Copy pathTASK3.py
File metadata and controls
58 lines (52 loc) · 2.28 KB
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
midday = []
midnight = []
for i in range(0, 4):
while True:
temperature_midday = raw_input("Enter the temperature for midday:\n")
try:
float(temperature_midday)
except ValueError:
print "This is not a number.\n"
continue
temperature_midday_float = float(temperature_midday)
if temperature_midday_float < -50 or temperature_midday_float > 60:
print "Sorry, your temperature is either too high or too low.\n"
else:
midday.append(temperature_midday)
print "Your temperature is recorded.\n"
break
while True:
temperature_midnight = raw_input("Enter the temperature for midnight:\n")
try:
float(temperature_midnight)
except ValueError:
print "This is not a number.\n"
continue
temperature_midnight_float = float(temperature_midnight)
if temperature_midnight_float < -50 or temperature_midnight_float > 60:
print "Sorry, your temperature is either too high or too low.\n"
else:
midnight.append(temperature_midnight)
print "Your temperature is recorded.\n"
break
max_midday_temperature = 0
min_midnight_temperature = 100
max_dayIndex = 0
min_nightIndex = 0
for day in range(0, len(midday)):
midday_temperature = float(midday[day])
if midday_temperature > max_midday_temperature:
max_midday_temperature = midday_temperature
max_dayIndex = day + 1
for night in range(0, len(midnight)):
midnight_temperature = midnight[night]
if midnight_temperature < min_midnight_temperature:
min_midnight_temperature = midnight_temperature
min_nightIndex = night + 1
print_text = ("The day with the highest midday temperature is Day", max_dayIndex,
". The temperature is", max_midday_temperature, "\nThe day with the lowest midnight temperature is Day",
min_nightIndex, ". The temperature is ", min_midnight_temperature, ".")
print "The day with the highest midday temperature is Day", max_dayIndex, "."
print "The temperature is", max_midday_temperature, "."
print "\nThe day with the lowest midnight temperature is Day", min_nightIndex, "."
print "The temperature is", min_midnight_temperature, "."