When we writing a number in
Python, it doesn’t accept things like these such as 11,111,111 or 11.111.111 or
11 111 111.
So, in Python we can write this
number like 11111111 or 11_111_111.
Python 3.6 has introduced underscores
in numeric literals, allowing for placing single underscores between digits and
after base specifiers for improved readability. This feature is not available
in older versions of Python.
Also in Python, we can write negative
numbers by adding minus mark (-) to the front of the number like these
-11111111 or -11_111_111.
Positive numbers don’t need to be
preceded by the plus sign (+). But it’s permissible, if we wish to do it. These
numbers describes the same number +11111111 and 11111111.
Octal Representation
0o123 is an octal number with a (decimal) value equal to 83.
The print() function
does the conversion automatically.
Hexadecimal Representation
If an integer number is preceded by a 0X or 0x prefix (zero-x), it will be treated as a hexadecimal value.
0x123 is a hexadecimal number with a (decimal) value equal to 291.
The print() function
does the conversion automatically.
No comments:
Post a Comment