GoConqr has a new look! Let us know what you think.

Module 4 of 24 · Text

Integers: octal and hexadecimal numbers

David Khieu

Integers: octal and hexadecimal numbers

There are two additional conventions in Python that are unknown to the world of mathematics. The first allows us to use numbers in an octal representation. 

If an integer number is preceded by an 0o or 0O prefix (zero-o), it will be treated as an octal value. This means that the number must contain digits taken from the [0..7] range only. 

0o123 is an octal number with a (decimal) value equal to 83.

The print() function does this conversion automatically. Try this: 

print(0o123)

The second convention allows us to use hexadecimal number. Such numbers should be preceded by the prefix 0x or 0X (zero-x)

0x123 is a hexadecimal number with a (decimal) value equal to 291. The print() function can manage these values too. Try this: 

print(0x123)

 

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?