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