Function Details: int

Description


Converts a number or string to an integer, or return 0 if no arguments are given.


Extended Description


The int() function returns an integer object constructed from a number or string x, or returns 0 if no arguments are given. If x is a number, it can be a plain integer, a float, or a number with a different base. If x is a string, it must be a sequence of digits in the given base (default 10). The optional base parameter specifies the base in which the string is interpreted.


Read More about int from Python Documentation

Function Signature


int(x: Union[str, Number, None] = None, base: Optional[int] = 10) -> int

Module: builtins

Class: int

Parameters



Parameter List


  • x: Union[str, Number, None]
  • base: Optional[int]

Return


Returns an integer object constructed from the given number or string.


Return Type


int

Output

Explanation

This example shows basic usage of int() with different types of input.