Базові типи даних
На цьому уроці розберемо основні типи даних у Python: числа, рядки, булеві значення та інші. Також розглянемо керування потоком виконання програми - умовні оператори, цикли та способи управління їх поведінкою.
Код і результати
Опублікована версія після Merge. Результати збережені автором; код на цій сторінці не запускається.
implementation.py · v1
price = 400.0
quantity = 3
promo = " python "
promo_discount = 0.1
subtotal = 0
for n in range(quantity):
subtotal = subtotal + price
promo = promo.strip().upper()
if promo == "PYTHON":
discount = subtotal * promo_discount
else:
discount = 0
subtotal_after_discount = subtotal - discount
print(subtotal_after_discount)
if subtotal_after_discount >= 1000:
delivery = 0
else:
delivery = 80
total = subtotal_after_discount + delivery
print(total)
print(f"{subtotal:.2f}")
print(f"{total:.2f}")
print(f"{discount:.2f}")
print(f"{delivery:.2f}")
Рев’ю спільноти
Approved. Can be merged.
