Interview Q&A / Python

INTERVIEW Q&A · 81 QUESTIONS

Python interview questions

Lists, dictionaries, generators, decorators and the Python questions asked in service-company and data roles.

  1. What does range() return in Python 3, and is it a list?

    range() returns a lazy range object, not a list. It stores only start, stop and step, so range(10**9) takes tiny memory, supports indexing, len() and the in operator, and produces numbers only when asked.

    BeginnerQuick answer1 min read