Challenge - 5 Problems
Assignment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of augmented assignment with strings
What is the output of this code?
Python
text = "Hi" text += " there" print(text)
Attempts:
2 left
💡 Hint
Remember that += adds to the existing string.
✗ Incorrect
The += operator adds the right string to the left string and updates the variable.
❓ Predict Output
intermediate2:00remaining
Value after augmented assignment with lists
What is the value of the list after running this code?
Python
numbers = [1, 2, 3] numbers += [4, 5] print(numbers)
Attempts:
2 left
💡 Hint
+= with lists extends the list by adding elements.
✗ Incorrect
The += operator extends the list by adding each element from the right list.
❓ Predict Output
advanced2:00remaining
Output of mixed augmented assignments
What is the output of this code?
Python
x = 5 x *= 2 x -= 3 print(x)
Attempts:
2 left
💡 Hint
Apply each operation step by step.
✗ Incorrect
x starts at 5, multiplied by 2 gives 10, then subtract 3 gives 7.
❓ Predict Output
advanced2:00remaining
Error raised by invalid augmented assignment
What error does this code raise?
Python
a = 10 b = "5" a += b
Attempts:
2 left
💡 Hint
You cannot add a string to an integer directly.
✗ Incorrect
Adding int and str with += causes a TypeError because they are incompatible types.
🧠 Conceptual
expert2:00remaining
Effect of augmented assignment on mutable vs immutable types
Which statement is true about augmented assignment (like +=) in Python?
Attempts:
2 left
💡 Hint
Think about lists vs strings and numbers.
✗ Incorrect
Mutable objects like lists are changed in place with +=, while immutable objects like strings and numbers create new objects.