JustCaptain kod-buduschego
987c64ff6f1070f722e2f060dc226970e8af6216
Перейти к файлу
Код
kod-buduschego Python 2025-20262.6. Цикл Forpracticeschatgpt2task_1.py
anc update c70a58f 8 октября 2026 г.
task_1.py
sales: list[int] = [120, 85, 230, 45, 99]
total: int = 0


# VERSION 1
for sale in sales:
    total += sale # 120 -> 85 -> 230 -> 45 -> 99

print("VERSION 1\nTotal revenue: {}".format(total))

# VERSION 2
total = 0
for index in range(len(sales)):
    total += sales[index] # sales[0] -> sales[1]
print("VERSION 2\nTotal revenue: {}".format(total))