開発者のための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入門