Challenge - 5 Problems
Math Operations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of complex math expression
What is the output of this Python code snippet?
Python
result = (3 + 5) * 2 ** 3 // 4 - 7 % 3 print(result)
Attempts:
2 left
💡 Hint
Remember the order of operations: parentheses, exponents, multiplication/division, addition/subtraction, and modulus.
✗ Incorrect
First, (3 + 5) = 8. Then 2 ** 3 = 8. Multiply 8 * 8 = 64. Integer divide 64 // 4 = 16. Then 7 % 3 = 1. Finally, 16 - 1 = 15. The output is 15, option B.
❓ Predict Output
intermediate2:00remaining
Result of math functions usage
What is the output of this code?
Python
import math value = math.ceil(math.sqrt(50)) + math.floor(math.log2(16)) print(value)
Attempts:
2 left
💡 Hint
Recall that sqrt(50) is about 7.07, ceil rounds up, log2(16) is exact.
✗ Incorrect
math.sqrt(50) ≈ 7.07, ceil(7.07) = 8. log2(16) = 4, floor(4) = 4. Sum is 8 + 4 = 12. So correct output is 12, option A.
❓ Predict Output
advanced2:00remaining
Output of math with negative and float values
What is the output of this code snippet?
Python
import math x = -3.7 result = math.ceil(x) + math.floor(x) print(result)
Attempts:
2 left
💡 Hint
Remember how ceil and floor behave with negative floats.
✗ Incorrect
math.ceil(-3.7) is -3 (smallest integer >= -3.7), math.floor(-3.7) is -4 (largest integer <= -3.7). Sum is -3 + (-4) = -7.
🧠 Conceptual
advanced2:00remaining
Understanding integer division and modulus
Given the code below, what is the value of 'result' after execution?
Python
a = 17 b = 5 result = (a // b) * b + (a % b) print(result)
Attempts:
2 left
💡 Hint
Think about how integer division and modulus relate to the original number.
✗ Incorrect
Integer division a//b gives how many times b fits into a. Multiplying back and adding remainder (a % b) reconstructs the original number a. So result is 17.
🔧 Debug
expert2:00remaining
Identify the error in math expression
What error does this code raise when executed?
Python
import math value = math.sqrt(-1) print(value)
Attempts:
2 left
💡 Hint
Square root of a negative number is not defined in real numbers.
✗ Incorrect
math.sqrt() only works with non-negative real numbers. Passing -1 raises ValueError: math domain error.