map() — Python Technical Interview Questions & Answers
map()
map()
- map() is built into Python. You do not import it. Freshers only need one honest call and the printed result — not a long definition.
- map() — output: ['A', 'B']. map applies a function to each.
- Wrong type often raises TypeError. Empty values matter for bool/all/any. Don’t mix map up with a similar name (sorted vs sort, int vs float).
Technical Interview Tip: Call map() once and say what prints.
Code Examples for map()
Example
# map()
print(list(map(str.upper, ["a", "b"])))
map() — output: ['A', 'B']. map applies a function to each.
How to Explain map() to an Interviewer
Explain map() as if you are teaching a junior — definition, then one tiny script.
map() is built-in — no import. One call + exact output.
What does the example print, and why?
map() — output: ['A', 'B']
What mistake do freshers make with map()?
Wrong type → TypeError.