6 Marks
6 Marks
Summer 22
i)
>>> a = [2, 5, 1, 3, 6, 9, 7 ]
>>> a [ 2 : 6] = [ 2, 4, 9, 0]
ii)
iii)
>>> t1 = [ 3, 5, 6, 7 ]
c) Write a program to open a file in write mode and append some contents at the end of file.
Summer 23
b) Write a Python program to calculate sum of digit of given number using function.
c) Write a Python Program to accept values from user in a list and find the largest number and smallest
number in a list
b) Design a class student with data members : name, roll no., department, mobile no. Create suitable
methods for reading and printing student information.
summer 24
a) Write the output for the following if the variable course = “Python”
>>> course [ : 3 ]
>>> course [ 3 : ]
>>> course [ 2 : 2 ]
>>> course [ : ]
>>> course [ -1 ]
>>> course [ 1 ]
b) Write a python program to generate five random integers between 10 and 50 using numpy library.
c) Write a Python program to create a class ‘Diploma’ having a method ‘getdiploma’ that prints “I got a
diploma”. It has two subclasses namely ‘CO’ and ‘IF’ each having a method with the same name that
prints “I am with CO diploma” and ‘I am with IF diploma’ respectively. Call the method by creating an
object of each of the three classes.
b) Write a Python program to create user defined exception that will check whether the password is
correct or not.
Winter 24
c) Design a class student with data members; Name, Roll No., Address. Create suitable method for
reading and printing students details.
b) Write a Python program to read contents of first.txt file and write same content in second.txt file.
c) Explain Try-except-else-finally block used in exception handling in Python with example.