12. Short Q&A Prompts

Quick drills to practice clarity and coverage under time pressure.

Tip: when answering, define the concept in 1 sentence, give a tiny example, and note 1–2 practical trade-offs.

  • What does s[a:b:c] mean and how do negative indices work?
  • Why are mutable default arguments dangerous and how do you avoid them?
  • List vs tuple: when would you choose each?
  • How do you copy a list safely? Shallow vs deep copy.
  • What’s the difference between is and ==? Give an example.
  • Explain LEGB with a quick example.
  • EAFP vs LBYL: when is each preferable?
  • What does enumerate return? When would you use zip?
  • Write a list comprehension and a generator expression that produce even numbers 0..8.
  • How do context managers help? Show the with open(...) pattern.
  • Threading vs multiprocessing vs asyncio: pick one for I/O vs CPU.
  • Big-O for dict lookup and list insert at the beginning.