Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
Python Numbers

Python Numbers

May 20th, 2019

Python Numbers

  •  Python will be supported at multiple data type integer, float, Boolean
    and complex data type.
  • By default, the interpreter preference considers the data type
    depends upon simultaneous the usage of number.
Example code :
 int= 10
print type(inte)
print type(floate)
print type(boolean)
print type(complexe)
Output :
<type 'int'>
<type 'float'>
<type 'bool'>
<type 'complex'>

Decimal Number

This becomes under regular character form which we are doing in general. We can also request it a base 10 format.

Octal number

  • Oct() function methods are one of the built-in methods using python.
  • Oct() python method will be taken as an integer and return.
  • Oct() python function data type value representation in string format.
Example Code:
print(oct(dec),"in octal.")

Binary Number

print(bin(dec),"in binary.")
Output :

Hexa Decimal Number

The hexadecimal number variable called 16. if the python hexadecimal
value prefixed with “0x” or “0X”.

Syntax :

Parameters :
x - an integer number (int object)
Returns: Returns hexadecimal string.
Example :
print("hexadecimal data value form of 16"
+ hex(16))
print("The hexadecimal value"
"from the ascii value 'a' is " + hex(ord('a')))
print("The hexadecimal value form of 2.6 is "
+ float.hex(2.6))