Challenge - 5 Problems
Operator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this expression with mixed operators?
Consider the following Python expression. What will it print?
Python
result = 3 + 4 * 2 ** 2 - 5 // 2 print(result)
Attempts:
2 left
💡 Hint
Remember the order: exponentiation, then multiplication/division, then addition/subtraction.
✗ Incorrect
Exponentiation (2 ** 2) is 4, then multiplication (4 * 4) is 16, integer division (5 // 2) is 2, so 3 + 16 - 2 = 17.
❓ Predict Output
intermediate1:30remaining
What is the output of this chained comparison?
What does this code print?
Python
x = 5 print(1 < x < 10)
Attempts:
2 left
💡 Hint
Python supports chaining comparisons like this.
✗ Incorrect
The expression 1 < x < 10 checks if x is greater than 1 and less than 10 simultaneously. Since x is 5, this is True.
❓ Predict Output
advanced2:00remaining
What is the output of this expression with logical and bitwise operators?
What will this code print?
Python
a = 0b1010 b = 0b1100 result = a & b == 0b1000 print(result)
Attempts:
2 left
💡 Hint
Remember operator precedence: & has higher precedence than ==.
✗ Incorrect
The expression a & b == 0b1000 is evaluated as (a & b) == 0b1000. a & b is 0b1000 (8), so the comparison is True.
❓ Predict Output
advanced2:00remaining
What is the output of this expression with mixed boolean and arithmetic operators?
What does this code print?
Python
x = 3 result = x > 2 and x < 5 or x == 10 print(result)
Attempts:
2 left
💡 Hint
Remember that 'and' has higher precedence than 'or'.
✗ Incorrect
The expression is evaluated as (x > 2 and x < 5) or (x == 10). Since x is 3, x > 2 and x < 5 is True, so the whole expression is True.
❓ Predict Output
expert2:30remaining
What is the output of this complex expression with assignment and arithmetic?
What will this code print?
Python
x = 2 x *= 3 + 4 print(x)
Attempts:
2 left
💡 Hint
Remember operator precedence: '+' is evaluated before '*='.
✗ Incorrect
The expression x *= 3 + 4 is evaluated as x *= (3 + 4), so x = 2 * 7 = 14.