0
0
Pythonprogramming~20 mins

Why Python is easy to learn - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Python Easy Learner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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"))
AHello, Alice!
BHello Alice
Cgreet(Alice)
DError: name not defined
Attempts:
2 left
💡 Hint
Look at how the function uses f-strings to insert the name.
🧠 Conceptual
intermediate
1: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?
ABecause it hides the code structure from the programmer
BBecause it forces code to be visually organized and easy to read
CBecause it makes the code run faster
DBecause it allows writing code without any spaces
Attempts:
2 left
💡 Hint
Think about how you read a book or a recipe with clear sections.
Predict Output
advanced
2: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)
AError: invalid syntax
B[1, 4, 9, 16]
C[2, 4]
D[4, 16]
Attempts:
2 left
💡 Hint
Look at the condition 'if x % 2 == 0' which filters even numbers.
🔧 Debug
advanced
1: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)
ATypeError
BSyntaxError
CValueError
DNameError
Attempts:
2 left
💡 Hint
Think about what happens when you try to add different data types.
🚀 Application
expert
2: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))
A7
B5
C6
D4
Attempts:
2 left
💡 Hint
Remember that keys in a dictionary are unique and can be updated.