Are you ready?
1 questions to solve.
- This quiz goes to full-screen once you press the Start button, or any Next button after exiting the quiz window.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
0xffis a Python integer represented in hexadecimal format. It denotes the integer
0b101denotes the integer
5, in binary format. This goes with choice (D).
b, used to denote binary numbers in Python, is case-insensitive. That is, it doesn't matter if we use it as
B. This means that
0b111are both indeed equivalent.
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.
bin()function converts a given integer into a binary string. Hence,
hex()function converts a given integer into a hexadecimal string. Hence,
oprefix in Python integers denotes octal numbers. Hence, the correct choice is (B).