Nettms · Building TomorrowAcademy of AI &
Engineering
Jobs
Free Learnings
For companiesTeach
Sign inStart free →
Interview Questions

Python Interview Questions & Answers

Frequently asked Python interview questions with concise answers — data types, comprehensions, functions and pandas basics. Practise them in a free AI mock interview.

Practise these in a free AI mock interview
  1. 1. What is the difference between a list and a tuple?

    Lists are mutable and use []; tuples are immutable and use (). Use tuples for fixed collections and as dictionary keys, and lists for data that changes.

  2. 2. What is a dictionary in Python?

    An insertion-ordered collection of key-value pairs with fast lookups by key, written {}. Keys must be unique and hashable.

  3. 3. Explain list comprehension.

    A concise way to build a list: [x*x for x in range(5)] gives [0, 1, 4, 9, 16]. It is more readable and often faster than a for-loop with append.

  4. 4. Difference between == and is?

    == compares values (are they equal?); is compares identity (the same object in memory?). Use == for value checks and is mainly for None.

  5. 5. What are *args and **kwargs?

    *args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dict. They let a function accept a variable number of arguments.

  6. 6. What is a lambda function?

    A small anonymous function, e.g. square = lambda x: x*x. Handy for short throwaway functions such as a key in sorted().

  7. 7. Difference between append() and extend()?

    append(x) adds x as one element; extend(iterable) adds each element of the iterable. [1,2].append([3,4]) gives [1,2,[3,4]]; extend gives [1,2,3,4].

  8. 8. What is a Python decorator?

    A function that wraps another to add behaviour (logging, timing, auth) without changing its code, applied with @decorator syntax.

  9. 9. How does Python manage memory?

    Through reference counting plus a cyclic garbage collector that frees objects no longer referenced. You usually do not manage memory manually.

  10. 10. What are pandas Series and DataFrame?

    A Series is a 1D labelled array (like a column); a DataFrame is a 2D labelled table of rows and columns. They are the core structures for data analysis in pandas.

  11. 11. What is the difference between a shallow copy and a deep copy?

    A shallow copy copies the outer object but shares the nested objects; a deep copy (copy.deepcopy) duplicates everything. Changing a nested item in a shallow copy also changes the original.

  12. 12. What is a generator?

    A function using yield that produces values one at a time on demand instead of building a whole list in memory — efficient for large or streaming data.

  13. 13. What is the difference between a module and a package?

    A module is a single .py file; a package is a directory of modules (with an __init__.py). Packages organise larger codebases into namespaces.

  14. 14. What is a set and when do you use it?

    An unordered collection of unique items. Use it to remove duplicates or to do fast membership tests and set operations like union and intersection.

  15. 15. What is the GIL (Global Interpreter Lock)?

    A lock that lets only one thread run Python bytecode at a time, which limits CPU-bound threading. Use multiprocessing for CPU work, or async and threads for I/O-bound work.

  16. 16. What is the difference between range and a list?

    range is a lazy sequence that generates numbers on demand and uses almost no memory; a list stores all its values. Iterating range(1_000_000) does not build a million-element list.

  17. 17. What are mutable and immutable types in Python?

    Immutable types (int, str, tuple, frozenset) cannot change after creation; mutable types (list, dict, set) can. Mutability affects copying, default arguments and what can be a dictionary key.

  18. 18. How do you handle exceptions in Python?

    Use try/except, optionally with else and finally. Catch specific exceptions rather than a bare except, use finally for cleanup, and re-raise with raise when you cannot handle the error.

  19. 19. What is a context manager (the with statement)?

    An object that sets up and cleans up a resource automatically. with open(path) as f: closes the file even if an error occurs, which prevents resource leaks.

  20. 20. What does if __name__ == "__main__" do?

    It runs the code below it only when the file is executed directly, not when it is imported as a module — handy for files that are both importable and runnable.

  21. 21. How do you read a CSV and get quick stats in pandas?

    df = pd.read_csv("file.csv"), then df.head() to preview, df.info() for types and nulls, and df.describe() for summary statistics of the numeric columns.

  22. 22. What is the difference between apply, map and applymap in pandas?

    map works element-wise on a Series, apply works on a Series or along a DataFrame axis, and applymap works element-wise across an entire DataFrame.

  23. 23. What is list slicing?

    Taking part of a sequence with [start:stop:step]. a[1:4] returns elements 1 to 3, a[::-1] reverses the list, and a[:3] takes the first three.

  24. 24. What is the difference between remove(), pop() and del?

    remove(value) deletes the first matching value, pop(index) removes and returns the item at an index (the last by default), and del removes by index or slice without returning anything.

  25. 25. What is a Python virtual environment?

    An isolated folder with its own Python and packages so each project has independent dependencies. Create it with python -m venv .venv and activate it before installing packages.

Knowing the answers isn’t enough — say them out loud

Practise these Python questions in a free AI mock interview: answer by voice, get instant feedback on your strengths and the gaps to fix.

Start a free mock interviewBuild a free resume

Admissions open · free to apply

Request your admission

Attended a masterclass or have a friend's referral code? You get ₹15,000 off. Fill this and our team takes it from here — pay by cash or online.

Nettms · Building TomorrowAcademy of AI &
Engineering

Free masterclasses, live cohorts, and pan-India placement support. Building Tomorrow.

ISO CertifiedStartup IndiaPractitioner-taught

Programs

  • Applied AI Engineer
  • Data Analysis with Gen AI
  • BIM
  • All programs

Free Tools

  • Code Compiler
  • Python Playground
  • Pandas Playground
  • SQL Playground
  • AI Glossary
  • Success Stories

Free Learning

  • Free Masterclass
  • Free Learnings
  • Free Admission
  • Blog
  • Events
  • WhatsApp Channel
  • Newsletter

Workshops

  • AI Workshop
  • BIM Workshop
  • Refer & Earn

Company

  • About
  • Hire with us
  • Careers at Nettms
  • Become a trainer
  • Contact
  • Privacy
  • Terms
  • Refund policy

Get the weekly drop.

One email a week — career insights, free masterclass invites, and what India's top employers are hiring for.

© 2026 Nettms Urban Habitat Pvt. Ltd. · 🌱 Building Tomorrow

Hyderabad, India

  • Home
  • Programs
  • Practice
  • Free
  • Account