MAHARAJA INSTITUTE OF TECHNOLOGY MYSORE
BELAWADI, NAGUVANAHALLI POST, SRIRANGAPATNA TALUK, MANDYA-571
477
Question Bank
Module 1 (Python Basics, Flow Control, Functions, Scope, Exception Handling)
1. With Python programming examples, explain the syntax and control-flow diagrams of
break and continue statements.
2. Explain two methods of importing modules into a Python program. Which method is
best? Illustrate with examples
3. What is a flow-control statement? With a flow chart, discuss if and if-else statements.
4. Explain the scope rules of variables in Python. Differentiate between local and global
scope with examples.
5. How can you prevent a Python program from crashing? Discuss exception handling in
Python, and write a program to handle division-by-zero.
6. Explain the features and advantages of Python over other programming languages.
7. Write a Python program to check whether a number is prime or not.
8. Explain different types of operators in Python with examples.
9. Write a Python program to find the factorial of a number using loops.
10. What are the different data types in Python? Explain with examples.
11. Explain input and output functions in Python with examples.
12. Explain conditional statements in Python with suitable examples.
13. What is indentation in Python? Why is it important?
14. Explain the difference between mutable and immutable data types with examples.
Module 2 (Lists, Dictionaries, Data Structures)
1. Explain with programming examples: negative indexing, slicing, methods like append(),
remove(), pop(), insert(), sort() on lists.
2. For a = ['hello', 'how', [1,2,3], [[10,20,30]]], what is the output of the
following statements?
o print(a[::])
o print(a[-3][0])
o print(a[2][:-1])
o print(a[0][::-1])
3. Explain the methods get() and setdefault() in dictionaries with examples.
4. Explain various string operations in Python with examples.
5. Differentiate between list and tuple with examples.
6. What is a dictionary? Explain with examples of adding, deleting, and updating key-value
pairs.
7. Compare lists, tuples, and sets based on mutability and use cases.
8. Explain the use of slicing and indexing in lists with examples.
Module 3 (Strings, File I/O, OS modules)
1. Explain string-handling methods such as .join(), .split(), .isalpha(), .isalnum(),
.isspace() with examples.
2. Explain, with suitable Python program segments, [Link]() and
[Link]().
3. What are functions in Python? Explain with an example of a user-defined function.
4. Differentiate between local and global variables with examples.
5. What are modules in Python? Explain how to import and use them.
6. Explain default, keyword, and variable-length arguments with examples.
Module 4: Organizing Files & Debugging
1. Explain the functions in the shutil module for copying, moving and deleting
files/folders. Give Python examples.
2. What are the benefits of compressing folders/files? Demonstrate how to create a .zip file
from a given directory, and how to read/extract a .zip file in Python.
3. Explain the process of walking through a directory tree (all sub-folders and files) in
Python. Write a program to count all files of a certain type (e.g., “.txt”) in the directory
tree.
4. a) Discuss raising exceptions and using assertions in Python. b) What is logging? Explain
the logging levels and show how logging can help debug a factorial-calculator program.
5. Describe how you can debug a Python program using IDLE’s debugger. What are the
advantages of using built-in debugging tools rather than just print statements?
Module 5:Classes, Objects & Object-Oriented Programming
1. What is a class in Python? How do you define a class and instantiate its objects? Explain
with an example (e.g., a simple Employee class).
2. Define the terms: object, attribute, method. Create a class Rectangle with attributes
height, width and starting_point (x,y). Write methods to compute the centre point
and display rectangle details.
.
3. What is a “pure function” and what is a “modifier” in the context of object-oriented
Python? Illustrate with a class Time and a function that either modifies the object or
returns a new object.
4. Explain the special methods __init__ and __str__ in Python classes. Write a class
Complex to represent complex numbers, and show how __str__ can be used to print
objects nicely.
5. a) What is operator overloading? Show how you can overload the + operator for the
Complex class to add two complex numbers. b) What is polymorphism in object-oriented
programming? Give examples in Python (e.g., method overloading / different types) and
explain its significance