Pythonでは、たとえ4 / 2のように割り切れる計算でも、/演算子を使った結果はintの2ではなく、floatの2.0になる、というルールがあるためです。 このように非常に身近なfloat型ですが、実は**int型にはない、致命的な「罠」**が潜んでいます。
a = 10 b = 3 result = a * b print(result) # 30 べき乗 (**) result = 2 ** 3 # 2の3乗 print(result) # 8 result = 5 ** 2 # 5の2乗 print(result) # 25 摂氏30度 ...
basic Python project that demonstrates typecasting. We'll create a simple program that allows the user to input different types of data, and the program will typecast those inputs to various other ...
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する