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
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Python program to get location meta data from an image
Retrieve Twitter posts and comments using Python
How to install Jupyter in Ubuntu and make it accessible through Apache Reverse Proxy
Python Basics - Setting up your Python Development Environment
Schwartzian Transform in python
Multidimensional list (array) in python
Perl's chomp() equivalent for removing trailing newlines from strings in python