Python Number Basics Quiz

Quiz 2 9 questions

Prerequisites for the quiz

  1. Python Number Basics

Are you ready?

9 questions to solve

Instructions
  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.
Python has two different classes for integers and floats. True or false?
Yes, Python indeed has two different classes for integers and floats. The int class represents integers while the float class represents floats. See more at Python Number Basics.
What does 3 // 2 return?
The // operator computes floor division. That is, it performs normal division and then floors the result. So 3 // 2 returns 1, which goes with choice (A). Read more at Python Number Basics — floor division.
What does 4 / 2 return?
The / division operator in Python returns a float, even if the result is an integer. Therefore 4 / 2 returns 2.0, NOT 2. This goes with choice (B). More details at Python Number Basics.
What does 1e3 return?
The e symbol in numbers denotes scientific notation. The number preceding it represents the significand while the number following it represents the order of magnitude (the power of 10). Moreover, it returns a float.

Hence, 1e3 represents the number 1000.0, which goes with choice (D). See more at Python Number Basics — the e symbol.
What does type(10) return?
The type() function takes in a given value and returns back the class that represents it. type(10), likewise, returns back the class int, since 10 is an integer in Python belonging to the class int. For more details, refer to Python Number Basics — integers.
What does int() return?
When called without an argument, int() returns 0. Hence, the correct choice is (A).
How to check if a float f represents an integer i.e has a fractional part equal to 0?
We can call f.is_integer() to see if the float f represents an integer. It would return True on integer floats such 10.0, and False otherwise. See more at Python Number Basics — float.is_integer().
What is the difference b/w the ** exponentiation operator and the pow() function?
The pow() function additionally enables one to perform fast modular exponentiation, by providing a third, optional argument. Hence the correct choice is (B). For a comprehensive discussion on the difference b/w ** and pow(), refer to Python Number Basics — difference between ** and pow().
What does 3e100000 resolve down to?
3e100000 represents an extremely large float, that can't be held on in Python's double-precision format. Python evaluates it to inf i.e infinity. Hence, the correct choice is (A). For more details, refer to Python Number Basics — floats.

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

— Bilal Adnan, Founder of Codeguage