Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesPython FoundationsModule 2 · Data structuresList inclusionwrite20 / 174
+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]`
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

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