> Python contains 3 types of numeric values: integers, floating-point numbers, and complex numbers.
Integer
Integers are represented in Python in four ways, binary, octal, decimal, hexadecimal. Humans use decimal for the representation of numeric values, so the final output of the Python interpreter is decimal regardless of the method used.
Integer constants
Binary starts with 0b or 0 B followed by a value:
in [+]: 0b10out[]: 2 in[]: 0b11out[56]: 3
Octal starts with 0o or 0O followed by a value:
In []: 0o17out[]:[Max]: 0o20out[61]: 16
Decimal is the default constant and can be entered directly into the value:
in [+]:out[[]: Ten in[]:out[63]: 20
Hexadecimal starts with 0x or 0X followed by a value:
in [+]: 0x18out[]:[+]: 0x24out[65]: 36
constructor function
In addition to creating integers directly using constants, you can also use the constructor int () to create integers, using integer constants or decimal numeric strings in int:
In [the]: Int (0B11) out[[3]: Int (0B11) out[]: 3 in[]: Int (0B11) out[ [3]:int (0o11) out[]: 9 in[]: Int (one) out[): one in[74] : Int (0x21) out[":[+]: Int ('1') out[75]: 1
Python's numeric type