Hexadecimal and Octal integers in python

By: Python Documentation Team  

To specify an octal digit, precede the octal value with a zero, and then a lower or uppercase 'o'. For example, to set the variable 'a' to the octal value '10' (8 in decimal), type:

>>> a = 0o10
>>> a
8

Hexadecimal is just as easy. Simply precede the hexadecimal number with a zero, and then a lower or uppercase 'x'. Hexadecimal digits can be specified in lower or uppercase. For example, in the Python interpreter:

>>> a = 0xa5
>>> a
165
>>> b = 0XB2
>>> b
178




Archived Comments

1. Karine
View Tutorial          By: payday loans line feed at 2012-06-23 16:35:42


Most Viewed Articles (in Python )

Latest Articles (in Python)

Comment on this tutorial