Введение в Python для разработчиков
Jasmin Ludolf
Senior Data Science Content Developer
$$
$$
$$
new_ingredient_quantity = 1.5
$$
$$
is_in_stock = True
is_in_stock = False
type()
Строка
ingredient_name = "tomatoes"print(type(ingredient_name))
<class 'str'>
Целое число
ingredient_quantity = 2print(type(ingredient_quantity))
<class 'int'>
Число с плавающей точкой
new_ingredient_quantity = 1.5print(type(new_ingredient_quantity))
<class 'float'>
Логическое значение
is_in_stock = Trueprint(type(is_in_stock))
<class 'bool'>
type() для определения типа
Арифметические операторы:
+ — сложение- — вычитание* — умножение/ — делениеЧисла:
print(2 + 1.5)
3.5
Строки:
+ и *"Hi" + "There" = "HiThere"
"Hi" * 3 = "HiHiHi"
Введение в Python для разработчиков