TGViewer
Python Learning Python Learning @python_bds · 5.74K subscribers
Post #1247 694
✅ Python Scenario-Based Interview Question – List Comprehension 🐍

Scenario:
You are given a list of numbers:
numbers = [1, 2, 3, 4, 5, 6]


Question:
Write Python code to create a new list that contains:
1. Only the even numbers from the original list.
2. Each even number multiplied by 2.

Expected Output:


Answer:
even_doubled = [num * 2 for num in numbers if num % 2 == 0]
print(even_doubled)

Explanation:
⦁ The list comprehension iterates over each num in numbers.
⦁ The if num % 2 == 0 condition filters to only even numbers (remainder 0 when divided by 2).
⦁ For those, num * 2 doubles them, building the new list concisely.
  • ❤ 5
More from @python_bds
  1. Oct 8, 2026🐛 This Python Bug Looks Random, But It Isn't Look at this: functions = [] for i in range(…
  2. Oct 6, 2026🐍 Python Performance Optimization Python Performance Optimization: Make Your Code Faster…
  3. Oct 4, 2026Python Set Methods ✍️
  4. Oct 3, 2026Post #1310
  5. Oct 1, 2026🐍 Python Beginner Notes
  6. Sep 30, 2026🧠 return vs print() in Python These are not interchangeable. def add(a, b): print(a + b)…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →