print(int('45')) # 45
Using float data type as input
print(int(4.5)) # 4
print(int(4.78)) # 4
print(int(4.99)) # 4
print(int(4.1)) # 4
print(int('0101',2)) # 5
octal base
print(int('107',8)) # 71
Base is 16 here
print(int('ca',16)) # 202
print(int(123,16)) # Error
This will generate output
my_data='1011' # string input
print("With base 2 : ",int(my_data,2)) # 11
my_data='71'
print("with base 8 :",int(my_data,8)) # 57
my_data='cd'
print("with base 16 :",int(my_data,16)) # 205
Output
With base 2 : 11
with base 8 : 57
with base 16 : 205
a=None
b=int(a) #TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
print(b)
Solution , use like this and assign 0 if it is None
a=None
b=int(a or 0)
print(b) # 0

Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.