Name

int()

Examples
# Convert floating point number             
f = 65.8                                 
i = int(f)                                  
print(f) # Prints 65
																						
# Convert from string                       
s = "1234"                                  
i = int(s)                                  
print(i) # Prints 1234
																						
# Convert from string with base             
s = "1234"                                  
i = int(s, 16) # base 16 (hexidecimal)   
print(i) # Prints "4660" 
Description Converts a non-integer type (such as a floating-point number or string) to its integer representation.
Syntax
	int(value)
int(value, base)
Parameters
valuethe value to convert to an integer
baseif value is a string, the base to perform the conversion in

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.