Siddaganga Institute of Technology, Tumakuru
Python Programming – Previous Year Questions (Unit-wise)
UNIT 4: File Operations, Shutil, Debugging & OOP Intro
■ April-May 2023 (PLC2)
Q7a Write a code snippet to illustrate how [Link]() function works in python. [6M]
Q7b Write a python program to read and extract zip files. [8M]
Q7c What is assertion? Explain in detail with an example program. [6M]
— OR —
Q8a Write a python program to demonstrate the safest way of deleting a folder or a file. [6M]
Q8b Differentiate between [Link]() and [Link]() methods. [6M]
Q8c Write a program to calculate a factorial of a number. Show the output for a given number.
[8M]
■ July-Aug 2024 (S3CCSI05)
Q7a Describe objects used in python programming language with a neat diagram. [6M]
Q7b Write a python program to demonstrate multiple inheritance. [6M]
Q7c Explain and illustrate the creation of classes and objects in python with a suitable program.
[8M]
— OR —
Q8a Write a python program to demonstrate base and derived class relationship without using
init() method in a derived class. [6M]
Q8b Explain the polymorphism with an example program. [6M]
Q8c Write python program to calculate the arc length of an angle by assigning values to the
radius and angle data attributes of the class ArcLength and also write object diagram for
ArcLength class. [8M]
■ Aug-Sept 2024 Supplementary (PLC2)
Q7a Illustrate copying, moving and renaming of files using shutil module along with examples.
[8M]
Q7b Develop a program to compress the files and read the Zip files in Python using ZIPFILE
module. [8M]
Q7c Differentiate between [Link]() and [Link](). [4M]
— OR —
Q8a Discuss the significance of raising exception and assertion statements in Python
programming language along with an example. [10M]
Q8b Discuss the significance of five logging levels used in Python programming. [10M]
■ July-Aug 2024 (PLC2 - 2nd Sem)
Q7a Illustrate with suitable examples the purpose of Shutil module. Also show how to copy,
move, rename and delete files using Shutil module functions. [10M]
Q7b What are logging levels? Illustrate the functions of five logging levels from least to most
important with suitable example for each. [10M]
— OR —
Q8a Develop a python program to guess the number. [6M]
Q8b Write a logic to read the ZIP files in python. [6M]
Q8c Illustrate with suitable example how creating and adding ZIP files are done in python. [8M]
■ March 2024 (S3CCSI05)
Q7a Implement a class called country, which represents a country with a name, a population, and
an area. Define country with a constructor that has four parameters: country, name,
population and its area. [8M]
Q7b Differentiate between class attribute and data attribute with an example. [6M]
Q7c Develop a python program to demonstrate private instance variables in python. [6M]
— OR —
Q8a Develop Python program to simulate a bank account with support for depositMoney,
withdrawMoney and showBalance operations. [8M]
Q8b Develop a Python program to illustrate Multiple parameters in __init__() method. [6M]
Q8c Illustrate Polymorphism in Python with an example program. [6M]
■ Sept 2023 (PLC2)
Q7a Illustrate the different methods of file operations supported to Python shutil module. [8M]
Q7b Explain the different steps involved in backing up a folder into a ZIP file. [8M]
Q7c Discuss the function used to rename files along with an example. [4M]
— OR —
Q8a Explain the significance of raising exception and assertion statement in Python programming
language along with an example. [10M]
Q8b Discuss all file accessing modes with illustrative examples, and write a Python program to
count and display the keywords from a Python source file. [10M]
■ Sept 2024 Supplementary (PLC2 & S3CCSI05)
Q7a Briefly explain different file operations supported by Shutil module. [10M]
Q7b Develop a program to back up a given folder into a zip file. Also display all the subfolders
and files present inside the backed up folder. [10M]
— OR —
Q8a Discuss five logging levels used in Python programming language along with disabling
logging messages. [10M]
Q8b Write a function named DivExp which takes into parameters a, b and returns a value c(a/b).
Write suitable assertion for a>0 in function and raise an exception when b=0. Develop a
program that reads two values from user and calls DivExp. [10M]
■ Sept 2024 Supplementary (S3CCSI05 - CS/AD/CI)
Q7a Discuss the static and class methods. [6M]
Q7b Explain the concept of Inheritance in Python. [6M]
Q7c Develop a program to demonstrate Polymorphism in Python. [8M]
— OR —
Q8a Create a Python class Person with attributes name and age. Create an object of class and
print person details. [6M]
Q8b Describe the need for __init__() constructor method with example program. [6M]
Q8c Create two base classes, named clock and calendar. Based on these two classes define
class CalendarClock, which inherits from both classes, which displays month details, date
and time. [8M]