TelegramOpen channel
Andrii Bezvesilnyi
Merged · Python

Базові типи даних

На цьому уроці розберемо основні типи даних у Python: числа, рядки, булеві значення та інші. Також розглянемо керування потоком виконання програми - умовні оператори, цикли та способи управління їх поведінкою.

Code and results

Published version after Merge. Results were saved by the author; code does not run on this page.

implementation.py · v1
price = 400.0
quantity = 3
promo = " python "
i = 1
subtotal = 0
#step 1
while i <= quantity: 
    subtotal += price
    i += 1

print(f"{subtotal:.2f}")
# step 2
if promo.strip().upper() == "PYTHON":
    discount = subtotal * 10 / 100;
    
    print(f"{discount:.2f}")
    
    subtotal = subtotal - discount;

# step 3
if subtotal > 1000:
  delivery = 0
else:
  delivery = 80
# step 4
print(f"{delivery:.2f}")

print(f"{subtotal:.2f}") 

# Порахуй subtotal циклом, потім discount, delivery і total.
# Виведи підсумок з двома знаками після крапки.

Community reviews

Osiychuk RomanApprove

Все вірно, код працюючий та читабельний.