Challenge - 5 Problems
Python Easy Learner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Python code?
Look at this simple Python code that uses clear and readable syntax. What will it print?
Python
def greet(name): return f"Hello, {name}!" print(greet("Alice"))
Attempts:
2 left
💡 Hint
Look at how the function uses f-strings to insert the name.
✗ Incorrect
The function greet returns a string with the name inserted using an f-string. So calling greet("Alice") returns 'Hello, Alice!'.
🧠 Conceptual
intermediate1:30remaining
Why does Python use indentation instead of braces?
Python uses indentation (spaces or tabs) to mark blocks of code instead of curly braces like some other languages. Why is this easier for beginners?
Attempts:
2 left
💡 Hint
Think about how you read a book or a recipe with clear sections.
✗ Incorrect
Indentation makes the code visually clear and easy to follow, which helps beginners understand the structure without extra symbols.
❓ Predict Output
advanced2:00remaining
What is the output of this list comprehension?
Python lets you write simple loops in one line. What does this code print?
Python
numbers = [1, 2, 3, 4] squares = [x**2 for x in numbers if x % 2 == 0] print(squares)
Attempts:
2 left
💡 Hint
Look at the condition 'if x % 2 == 0' which filters even numbers.
✗ Incorrect
The list comprehension squares only even numbers from the list, so it returns [4, 16].
🔧 Debug
advanced1:30remaining
What error does this code raise?
This code tries to add a number and a string. What error will it cause?
Python
result = 5 + "5" print(result)
Attempts:
2 left
💡 Hint
Think about what happens when you try to add different data types.
✗ Incorrect
Python cannot add an integer and a string directly, so it raises a TypeError.
🚀 Application
expert2:00remaining
How many items are in the dictionary after this code runs?
Python dictionaries store key-value pairs. How many pairs does this dictionary have after running the code?
Python
data = {x: x*2 for x in range(5)}
data[2] = 10
data[5] = 12
print(len(data))Attempts:
2 left
💡 Hint
Remember that keys in a dictionary are unique and can be updated.
✗ Incorrect
The dictionary starts with keys 0 to 4 (5 items). Updating key 2 does not add a new item. Adding key 5 adds one more item, so total is 6.