Базові типи даних
На цьому уроці розберемо основні типи даних у Python: числа, рядки, булеві значення та інші. Також розглянемо керування потоком виконання програми - умовні оператори, цикли та способи управління їх поведінкою.
Code and results
Published version after Merge. Results were saved by the author; code does not run on this page.
Python · 1
from os import DirEntry
price = 400.0
quantity = 3
promo = " python "
subtotal = discount = total = 0
delivery = 80
for i in range(quantity):
subtotal += price
print(promo.upper().strip())
if (promo.upper().strip() == "PYTHON"):
discount = subtotal * 0.10
total = subtotal - discount
if (total >= 1000):
delivery = 0
total += delivery
print("{:.2f}".format(subtotal), "{:.2f}".format(discount), "{:.2f}".format(delivery), "{:.2f}".format(total))
# Порахуй subtotal циклом, потім discount, delivery і total.
# Виведи підсумок з двома знаками після крапки.
Results saved by the author in Colab
PYTHON 1200.00 120.00 0.00 1080.00
Community reviews
Approved. Можна мерджати
