The value python

There are six types of values ​​in python

Types of Explanation
Integer int, an integer used to identify
Float float, represents a real number
Boolean bool, only 0 and 1
Complex types complex, complex labeling

Determining whether the variable is the value, if the value is converted

a='123'
print(a)       # 结果为:123
print(type(a)) # 结果为:<class 'str'>
b=a.isdigit()
print(b)       # 结果为:True
a=int(a)
print(type(a)) # 结果为:<class 'int'>

Detailed numerical conversion
https://blog.csdn.net/GrofChen/article/details/91356830
arithmetic operators value
https://blog.csdn.net/GrofChen/article/details/89320967

There are four integer representation systems: decimal, binary, octal, hexadecimal
python integer in the range is limited: 32bit computer is -2³¹ 2³¹ computer-1,64bit -2 ^ 63 ^ 2 63 -1

a=12
print(type(a)) #结果为:<class 'int'>

Float, for example: 2.2e4, e or E represents a group index is 10,4 Flag
range: -1.79e + 308 ~ 1.79e + 308

a=2.2E4
print(a) #结果为:22000.0

Boolean value, True and false when the arithmetic operation, True is 1, false 0

a=True
b=False
print(a+b) #结果为:1

Type complex, consists of two parts, for example: 1 + 0j, 1 is a real part and the imaginary part 0, j is the imaginary unit, the real and imaginary part are floating-point

a=1+0j
print(a)      # 结果为:(1+0j)
print(a.real) # 结果为:1.0
print(a.imag) # 结果为:0.0
print(type(a))# 结果为:<class 'complex'>

Guess you like

Origin blog.csdn.net/GrofChen/article/details/91379092