1. Numbers
Integer: int () converts a string or number to an integer
int(4.5) int('123')2, 8, hexadecimal to decimal
int('1010',2) '' is the number to be converted, 2 is used to indicate what base the preceding number is int('36',8) int('a',16)
Decimal → → Convert to binary bin() Convert to octal oct() Convert to hexadecimal hex()
float () converts integers and strings to floats
float(2) <<<2.0 float('123') <<<123.0
The # type() function returns the type of the object if you have only the first parameter , and the new type object for the three parameters.
a='123' b=456 print(type(a),type(b)) <class 'str'> <class 'int'>
- bit_lenght() # The binary of the current number, represented by at least n bits (the string cannot be measured)
age=23 r = age.bit_length()