Are you ready?
11 questions to solve
Instructions
- This quiz goes to full-screen once you press the Start button.
- At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
What does
round(3.78, 1)
return?When called with a positive second argument
The correct choice is therefore (B). For more details, refer to Python Rounding Numbers — the
n
, round()
rounds the given number to the digit in the n
th position to the right of the units digit. Likewise, round(3.78, 1)
rounds 3.78
to the 1
st digit after 3
, which is the digit 7
, yielding 3.8
.The correct choice is therefore (B). For more details, refer to Python Rounding Numbers — the
round()
function.What does
round(378.52)
return?When called without a second argument,
round()
rounds the given number to the nearest integer. In this case, round(378.52)
rounds 378.52
to 379
, which goes with choice (D). For more details, refer to Python Rounding Numbers — the round()
function.What does
round(168.83, -1)
return?When called with a negative second argument
The correct choice is therefore (D). For more details, refer to Python Rounding Numbers — the
n
, round()
rounds the given number to the digit in the n
th position to the left of the units digit. This means that round(168.83, -1)
rounds 168.83
to the 1
st digit before 8
, which is the digit 6
, yielding 170.0
.The correct choice is therefore (D). For more details, refer to Python Rounding Numbers — the
round()
function.What does
trunc(3.9)
return?The
trunc()
function removes the fractional part from a given number and returns back the left off integer. Thus trunc(3.9)
returns 3
, which goes with choice (B). For more details, refer to Python Rounding Numbers — truncation.What does
floor(10.9)
return?The
floor()
function returns the floor of a given number i.e the largest integer smaller than or equal to the number. Hence, floor(10.9)
returns 10
. For more details, refer to Python Rounding Numbers — floor and ceil.What does
ceil(9.03)
return?The
ceil()
function returns the ceil of a given number i.e the smallest integer greater than or equal to the number. Hence, ceil(9.03)
returns 10
. For more details, refer to Python Rounding Numbers — floor and ceil.floor()
and trunc()
return the same result on positive numbers. True or false?On positive numbers,
floor()
and trunc()
return the same result. Hence, the statement above is indeed true.ceil()
and trunc()
return the same result on positive numbers. True or false?Only on negative numbers, do the
ceil()
and trunc()
functions return the same result; NOT on positive numbers. Hence, the statement above is false.What does
round(3.5, 3)
return?By definition,
round(3.5, 3)
rounds 3.5
to 3 decimal places, but since it's not possible to add ending zeroes to the number, the result remains what it is i.e 3.5
. Hence, the correct choice is (A). For more details, refer to Python Rounding Numbers — the round()
function.What does
'{:.3f}'.format(70.8)
return?To see how the
format()
string method works, refer to Python Rounding Numbers — rounding in strings.What does
'{:.4f}'.format(10.93578)
return?To see how the
format()
string method works, refer to Python Rounding Numbers — rounding in strings.