Untitled
unknown
python
2 years ago
559 B
13
Indexable
temperatury = [10.5, 17.3, 12.8, 13.3, 11.2, 17.1, 19.8]
suma_temperatur = 0
for temperatura in temperatury:
# suma_temperatur = suma_temperatur + temperatura
suma_temperatur += temperatura # To jest uproszoczona wersja linijki wyżej
# suma_temperatur = 0
# temperatura = 10.5
# suma_temperatur = 0 + 10.5
# suma_temperatur = 10.5
# temperatura = 17.3
# suma_temperatur = 10.5 + 17.3
srednia = suma_temperatur / len(temperatury)
print(f'Suma temeratur wynosi: {round(suma_temperatur, 2)}')
print(f'Średnia temeratur wynosi: {round(srednia, 3)}')Editor is loading...
Leave a Comment