feat: python

This commit is contained in:
heyong.fu
2026-05-06 11:21:42 +08:00
commit 0abf1ad3c4
62 changed files with 7598 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
# 什么是浮点数?
# 浮点数是用来表示实数(包含小数点的数)的数据类型。在 Python 中,浮点类型用 float 表示。
pi = 3.1415926
temperature = -10.5
salary = 5000.00
scientific = 6.02e23 # 科学计数法:6.02 × 10²³
# 类型转换
# 使用float()函数进行类型转换
float_form_init = float(40)
print(float_form_init) # 40.0
float_form_str = float("99")
print(float_form_str) # 3.14
float_form_bool = float(True)
print(float_form_bool) # 1.0
float_form_false = float(False)
print(float_form_false) # 0.0
# 除法运算会产生浮点数
result1 = 10 / 2
print(result1) # 5.0
result2 = 7 / 2
print(result2) # 3.5