Viva Questions

Python viva questions and answers

Python viva questions with answers: data types, lists vs tuples, functions, OOP, modules, file handling, exceptions, libraries, plus questions on Python projects.

Ask on WhatsApp

What Python questions are asked in a viva?

Python vivas cover data types, the difference between list, tuple, set and dictionary, mutable versus immutable types, functions and lambda, OOP in Python, modules and packages, file handling, exception handling, and the libraries you used such as NumPy, pandas, Tkinter, Flask or Django.

Questions and answers

Is Python compiled or interpreted?

Python source is compiled to bytecode, which is then interpreted by the Python virtual machine. In practice it is called an interpreted language.

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; it is faster and can be used as a dictionary key.

What are mutable and immutable types?

Mutable objects can change after creation (list, dict, set). Immutable objects cannot (int, float, str, tuple).

What is a dictionary?

A collection of key-value pairs with unique, hashable keys and fast lookup.

What is the difference between a set and a list?

A set is unordered and stores unique elements; a list is ordered and allows duplicates.

What is PEP 8?

The official style guide for Python code: naming, indentation of four spaces, line length and layout.

What is a lambda function?

A small anonymous function written in one expression, for example lambda x: x * 2.

What are *args and **kwargs?

*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dictionary.

What is __init__?

The initialiser method that runs when an object is created and sets its attributes.

What is self?

A reference to the current object, passed as the first parameter of instance methods.

What is the difference between a module and a package?

A module is a single .py file. A package is a folder of modules, usually with an __init__.py file.

How do you handle exceptions in Python?

With try, except, else and finally blocks. Use raise to throw an exception.

What is the difference between deep copy and shallow copy?

A shallow copy copies the outer object but shares nested objects. A deep copy duplicates nested objects too.

What is list comprehension?

A compact way to build a list, for example [x * x for x in range(5)].

How do you read and write files?

Use open() with a mode such as 'r', 'w' or 'a', preferably inside a with block so the file closes automatically.

What is pip?

Python's package installer, used to install libraries from the Python Package Index.

What is a virtual environment?

An isolated folder with its own Python packages so that different projects do not conflict.

What is the difference between is and ==?

== compares values; is checks whether both names refer to the same object.

What are decorators?

Functions that wrap another function to add behaviour without changing its code, written with @name.

Which libraries did you use and why?

Name each library and its role, for example pandas for data cleaning, scikit-learn for the model, Flask for the web interface.

Questions on a Python ML project

  • Where did the dataset come from and how many records does it have?
  • How did you handle missing values?
  • How did you split training and testing data?
  • Which algorithm did you use and why not another?
  • What do accuracy, precision, recall and F1-score mean for your result?
  • What is overfitting and how did you check for it?

FAQs

Is this useful for MSBTE Python Programming (PWP 314004)?

Yes. It covers the oral topics of the K-scheme Python Programming course in the fourth semester.

Last reviewed: 2026-10-11. Always follow the format your own department gives you.

Need a hand with this?

Send your topic, deadline and your college's format. We will tell you what is pending and what to do first.