/  Int() method in Python Built in Function

Int() method in Python Built in Function

 

int method in built in function returns the integer from any number or string.

Syntax:

int (x, base=10)

 

Parameters:

Int method has two parameters

  • x: this is the number or the string which need to converted into integer object.
  • Base: this is the base of the number in x.

 

Example-1:

 

Using float

x = int(3.5)
print(x)

 

Output:

 

Example-2:

 

Using Integer

x = int(587)
print(x)

 

Output:

Int () method in Python Built in Function

 

Example-3:

 

Using string

x = int('985')
print(x)

 

Output:

Int () method in Python Built in Function