-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtepoloty.py
More file actions
32 lines (30 loc) · 910 Bytes
/
tepoloty.py
File metadata and controls
32 lines (30 loc) · 910 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
dni = 0
najvyssia_teplota = -274
with open("teploty.txt", "r") as teploty:
for riadok in teploty:
riadok = riadok.strip()
print(riadok + "°C")
riadok = int(riadok)
dni += 1
if riadok >= najvyssia_teplota:
najvyssia_teplota = riadok
den = dni
else:
continue
print("Meralo sa " + str(dni) + " dní")
print(
"Najvyššia teplota bola "
+ str(den)
+ " deň a bola "
+ str(najvyssia_teplota)
+ "°C"
)
""" "Michálikovo" (ChatGPT) riešenie
with open("teploty.txt", "r") as subor:
teploty = [float(riadok.strip()) for riadok in subor]
pocetDni = len(teploty)
print("Počet dní s meraním teploty: " + str(pocetDni))
najvyssiaTeplota = max(teploty)
najvyssiDen = teploty.index(najvyssiaTeplota) + 1
print("Najvyššia teplota bola " + str(najvyssiaTeplota) + "na den cislo " + str(najvyssiDen))
"""