# Python number# Python There are three types of numbers"""
int
float
complex
"""
x =1# int
y =2.8# float
z =1j# complex# If you want to verify the type of a variable,you can use the type() functionprint(type(x))print(type(y))print(type(z))# int# int integer,is a integer.It could be positive or negative,no decimal,and unlimited length.
x =1
y =3562254887
z =-35522print(type(x))print(type(y))print(type(z))# float# It could be contains decimal places,and could be positive or negative.
x =1.10
y =1.0
z =-35.59print(type(x))print(type(y))print(type(z))# scientific notation
x =35e3
y =12E4
z =-87.7e100print(type(x))print(type(y))print(type(z))# unreliable figure# It has "J" as the imaginary part
x =3+5j
y =5j
z =-5jprint(type(x))print(type(y))print(type(z))# type conversion
x =1# int
y =2.8# float
z =1j# complex
a =float(x)
b =int(y)
c =complex(x)print(a)print(b)print(c)print(type(a))print(type(b))print(type(c))# random number# python有一个内置模块random可以用来生成随机数# 示例:导入random模块,并显示1到10之间的一个随机数:import random
print(random.randrange(1,11))"""
Test
x 转换成浮点数
1.x = 5
x = float(x)
x 转换成整数
2.x = 5.5
x = int(x)
x 转换成复数
3.x = 5
x = complex(x)
"""
x =5
x =float(x)print(x)print(type(x))
x =5.5
x =int(x)print(x)print(type(x))
x =5
x =complex(x)print(x)print(type(x))
python基础-03# Python number# Python There are three types of numbers"""intfloatcomplex"""x = 1 # inty = 2.8 # floatz = 1j # complex# If you want to verify the type of a variable,you can use the type() functionprint(type(x))print(type(y)