Skip to main content
← CoursesPython FoundationsModule 2 · Data structuresList inclusionwrite19 / 170
💬 Discuss🧪 Playground+100 XP
Task
📝 **Task:** Use a list comprehension to get squares of even numbers from 1 to 10. 📋 **Steps:** 1. List comprehension shape: `[expr for item in range if condition]` 2. `range(1, 11)` covers 1..10 3. Keep only evens: `if x % 2 == 0` 4. Square: `x ** 2` 💡 **Similar example (cubes of odd numbers):** ```python cubes = [n ** 3 for n in range(1, 6) if n % 2 == 1] print(cubes) # [1, 27, 125] ``` 🎯 **Expected output:** `[4, 16, 36, 64, 100]`

Keep going

✏️ Write your code here
🐍
Loading Python...
First visit only — ~5-10s. Stays cached afterward.
📊 Result
Press Run to see result...
📣 Help someone learn PythonShare this lesson with a friend — the first 15 are free, no signup.Tweet

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…