Python Base n Representation Quiz

Quiz 4 7 questions

Prerequisites for the quiz

  1. Python Base n Representation

Are you ready?

7 questions to solve

  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
What does the number 0xff represent?
0xff is a Python integer represented in hexadecimal format. It denotes the integer 255.
What does the number 0b101 represent?
0b101 denotes the integer 5, in binary format. This goes with choice (D).
Are the two numbers 0B111 and 0b111 equivalent?
The prefix b, used to denote binary numbers in Python, is case-insensitive. That is, it doesn't matter if we use it as b or as B. This means that 0B111 and 0b111 are both indeed equivalent.
What does int('0b1111', 2) return?
The int() function converts a given numeric string into an integer based on the base denoted by its second parameter. In this case, int('0b1111', 2) converts the string '0b1111' into an integer based on the binary expansion, yielding 15. Hence, the correct choice is (A). For more details, refer to Python Base n Representation — converting from string to decimal.
What does bin(10) return?
The bin() function converts a given integer into a binary string. Hence, bin(10) converts 10 into '0b1010'.
What does hex(15) return?
The hex() function converts a given integer into a hexadecimal string. Hence, hex(15) converts 15 into '0xf'.
Which of the following number systems does the number 0o17 denote?
The o prefix in Python integers denotes octal numbers. Hence, the correct choice is (B).

"I created Codeguage to save you from falling into the same learning conundrums that I fell into."

— Bilal Adnan, Founder of Codeguage