Challenge - 5 Problems
Numeric Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of mixed int and float arithmetic
What is the output of this Python code?
Python
result = 5 + 3.0 * 2 print(result)
Attempts:
2 left
💡 Hint
Remember that multiplying an int by a float results in a float.
✗ Incorrect
Due to operator precedence, 3.0 * 2 = 6.0 (float), then 5 + 6.0 = 11.0.
❓ Predict Output
intermediate2:00remaining
Integer division vs float division
What is the output of this code snippet?
Python
a = 7 // 2 b = 7 / 2 print(a, b)
Attempts:
2 left
💡 Hint
// is floor division, / is true division.
✗ Incorrect
7 // 2 is 3 (integer floor division), 7 / 2 is 3.5 (float division).
❓ Predict Output
advanced2:00remaining
Float precision in arithmetic
What is the output of this code?
Python
x = 0.1 + 0.2 print(x == 0.3)
Attempts:
2 left
💡 Hint
Floating point numbers can have small precision errors.
✗ Incorrect
0.1 + 0.2 is not exactly 0.3 due to floating point precision, so the comparison is False.
❓ Predict Output
advanced2:00remaining
Type and value after mixed operations
What is the type and value of variable 'result' after running this code?
Python
result = int(4.7) + float(3)
Attempts:
2 left
💡 Hint
int(4.7) converts 4.7 to 4, float(3) converts 3 to 3.0.
✗ Incorrect
int(4.7) is 4 (int), float(3) is 3.0 (float), 4 + 3.0 is 7.0 (float).
🧠 Conceptual
expert2:00remaining
Behavior of float('inf') in arithmetic
Which option correctly describes the output of this code?
Python
import math x = float('inf') y = x - 1000 print(y == x)
Attempts:
2 left
💡 Hint
Infinity minus any finite number is still infinity.
✗ Incorrect
float('inf') represents positive infinity; subtracting a finite number does not change it, so y == x is True.