Skip to content
DevOps with Multi Cloud: new batch 25 Nov
novarynit: Training, Placement, Consulting

10 questions

Python interview questions and answers

Python questions for developer, data and automation roles: data types, functions, OOP and common built-ins.

What is the difference between a list and a tuple?
A list is mutable and written with square brackets. A tuple is immutable and written with parentheses, so it can be used as a dictionary key and is slightly faster.
What are *args and **kwargs?
*args collects extra positional arguments into a tuple. **kwargs collects extra keyword arguments into a dictionary. They let a function accept a variable number of arguments.
What is a decorator?
A decorator is a function that takes another function and returns a new one with added behaviour, applied with the @name syntax. Logging, timing and access checks are common uses.
What is the difference between shallow copy and deep copy?
A shallow copy creates a new container but keeps references to the same inner objects. A deep copy (copy.deepcopy) copies the inner objects too, so changes do not affect the original.
What is a list comprehension?
A compact way to build a list from an iterable, for example [x * x for x in nums if x > 0]. It is usually clearer and faster than an equivalent loop with append.
What is the GIL?
The Global Interpreter Lock in CPython allows only one thread to run Python bytecode at a time. Threads still help with I/O-bound work; CPU-bound work uses multiprocessing or native libraries.
What is the difference between is and ==?
== checks whether two values are equal. is checks whether two names refer to the same object in memory.
What are generators?
Functions that use yield to produce values one at a time. They keep their state between calls and do not hold the whole sequence in memory, which suits large data.
How is memory managed in Python?
Mainly by reference counting: an object is freed when no references remain. A cyclic garbage collector handles reference cycles.
What is the difference between a module and a package?
A module is a single .py file. A package is a folder of modules, traditionally marked with an __init__.py file, that can be imported with dotted names.

More topics

Next step

Practise these in a mock interview

Sit in a free demo class first. We will call you back in 5 minutes

  • See a live class before you join
  • Meet the trainer and review the syllabus
  • Get a batch and timing that fits you
  • Ask about EMI and placement support

Where to learn

  • Ameerpet, Hyderabad

    3rd Floor, Green House, Ameerpet, Hyderabad, Telangana

  • Live online

    Join the same class from anywhere, ask questions live and get the same project reviews.

Request your free demo

Takes 30 seconds. No payment needed.

+91

Free · no obligation

Book your free demo class

Leave your number and we will call you back.

  1. We will call you back in 5 minutes
  2. Attend a free demo class
  3. Join only if you like it