Course: Programming in Python L-T-P-C: 2-0-2-3
Course Code: CSEL102
Branches: CSE, CSM, CAI, CAD, CIC, ECE, and EEE
QUESTION BANK
Module-1: Python Programming Fundamentals
[Link] Short Answer Questions Marks
List out the various styles of comments supported
1 by the python, briefly explain about them in one 2M
line
Explain the difference between ‘is’ and ‘==’ with
2 2M
an example
3 Describe the purpose of range() function. 2M
Evaluate the output of the following code
a = [1, 3, 5, 7, 9, 11]
val = 7
x=1
for i in a:
4 if i == val: 2M
print("Found at", x, "iteration")
break
x += 1
else:
print("not found").
5 Define indentation in Python? Give an example. 2M
Display the odd numbers from 1 to n where n is
6 2M
the value provided by the user
Briefly explain about the dynamic typing in
7 2M
Python with an example.
Write a Python statement to declare multiple
8 variables in a single line and assign values to 2M
them. Give an example.
9 Find error and correct it: 2M
msg = "She said "Good Morning" to me"
print(msg)
Differentiate between input() and print() functions
10 2M
in Python.
[Link] Essay Answer Questions Marks
1 Develop a Python program to determine the 8M
disaster relief fund provided to a family based on
the type of house damage and annual income. The
program should accept the type of damage as a
character (F for fully damaged and P for partially
damaged) and the annual income of the family. If
the house is fully damaged and the annual income
is less than ₹3,00,000, the relief amount is
₹2,00,000; otherwise, the relief amount is
₹1,00,000. If the house is partially damaged and
the annual income is less than ₹3,00,000, the
relief amount is ₹1,00,000; otherwise, the relief
amount is ₹50,000. The program should calculate
and display the relief amount accordingly.
2 Develop a Python program to calculate the fine for 8M
overdue library books. The program should
prompt the user to enter the type of book as a
character, where r represents a reference book, g
represents a general book, and c represents a
children’s book, along with the number of days the
book has been delayed. Based on the category
selected, the fine must be calculated according to
the given rate structure, which is Rs. 20 per day
for reference books, Rs. 15 per day for general
books, and Rs. 10 per day for children’s books.
Finally, the program should compute and display
the total fine amount payable.
3 Implement a Python program to process loan 8M
applications for multiple applicants using a for
loop. The program should first accept the number
of applicants. For each applicant, input the
applicant’s name, age, annual income, and credit
score. An applicant is eligible for a loan only if the
age is between 21 and 60 (inclusive), the annual
income is at least ₹3,00,000, and the credit score
is 650 or above. If the applicant satisfies all the
conditions, calculate the loan amount as three
times the annual income. Otherwise, reject the
application. After processing all applicants,
display the total number of eligible applicants and
the total number of rejected applicants.
4 Implement a Python program to determine 8M
whether a given integer is a prime number using
an efficient approach. The program should accept
an integer input from the user and first handle the
special case where the number is less than or
equal to 1 by displaying that it is not a prime
number. For values greater than 1, the program
should check for divisibility only from 2 up to the
square root of the given number instead of
checking all numbers up to n-1. If any divisor is
found within this range, the program must display
that the number is not prime; otherwise, it should
display that the number is prime.
5 Implement a Python program to accept a string 8M
from the user and perform the following
operations:
1. Count the number of vowels and consonants
2. Display the string in reverse order
3. Check whether the given string is a
palindrome or not
6 Develop a Python program to accept a number n 8M
from the user and perform the following
operations:
1. Display all numbers from 1 to n
2. Print only the numbers divisible by both 3
and 5
3. Count how many such numbers exist
4. Compute and display the sum of these
numbers
Module-2: Sequences, Map and Sets
[Link] Short Answer Questions Marks
1 Define list and how it is created 2M
2 Explain remove() and discard() in python set. 2M
3 List any four dictionary methods 2M
4 List out the difference between lists and tuples? 2M
Describe the purpose of slicing and demonstrate
5 2M
with an example.
Evaluate the output of the following python
script?
6 2M
t = (5)
print(type(t))
What is list comprehension in Python? Give a
7 2M
simple example.
Differentiate between append() and extend()
8 2M
methods in Python lists with examples.
How are keys and values accessed in a
9 2M
dictionary? Give an example.
What is the difference between remove() and pop()
10 2M
methods in Python lists?
[Link] Essay Answer Questions Marks
1 Develop a Python program that asks the user to 8M
input two strings of equal length. If the lengths are
unequal, display a suitable message and
terminate. If the lengths match, construct a new
string by combining the lowercase version of
characters from the first string and the uppercase
version of characters from the second string at
corresponding positions, and print the resulting
string.
2 Design a Python program that generates a list of 8M
20 random numbers between 1 and 100. The
program should print the list, calculate and
display the average value, identify the highest and
lowest numbers, determine whether any duplicate
values exist in the list, count the number of
elements greater than 50, and display the total
count.
3 A social media platform wants to analyze user 8M
comments and find out how many times each word
appears in a comment. Users may type words in
different formats such as “Like”, “like”, or “LIKE”,
but the platform should treat all of them as the
same word. Develop a Python program that reads
a comment (sentence) from the user and displays
the frequency of each word using a dictionary. The
program should treat uppercase and lowercase
words as the same word. After writing the
program, explain how the dictionary helps in
counting the words and what would happen if the
sentence is not converted into lowercase before
counting.
4 A movie streaming platform needs to record the 8M
daily viewing details of its users. Each record
should contain the user’s name and the number of
hours watched in a day. Since the record should
not be changed once created, it must be stored as
a tuple. All user records should be stored inside a
list. Implement a Python program to accept the
viewing details of multiple users and store each
record in the form (user_name, hours_watched).
The program should display all user records,
identify the user who watched the maximum
number of hours, and calculate the total hours
watched by all users.
5 Write a Python program to manage student marks 8M
using a dictionary. The program should accept the
names of students and their corresponding marks
for a given number of students. The data must be
stored in a dictionary where the student name acts
as the key and the marks act as the value. After
storing the data, the program should display all
student records, identify and display the student
who has secured the highest marks, and finally
compute and display the average marks of all
students.
6 Develop a Python program using sets to perform 8M
various operations. The program should accept
two sets of elements from the user and display the
union, intersection, and difference of these sets. It
should also determine whether one set is a subset
of the other. Additionally, the program should
accept a list containing duplicate elements and
demonstrate how sets can be used to remove
duplicates, displaying the resulting list of unique
elements.
Module-3: Functions
[Link] Short Answer Questions Marks
Define a function in Python. Write the syntax for
1 2M
defining a function.
2 Differentiate between a function definition and a 2M
function call with an example.
What are default parameters in Python functions?
3 2M
Give an example.
Explain keyword arguments in Python with an
4 2M
example.
What are arbitrary arguments in Python
5 functions? Distinguish between *args and 2M
**kwargs.
What is variable scope in Python? List the different
6 2M
types of scope.
What is the difference between local variables and
7 2M
global variables?
Define higher-order functions in Python. Give one
8 2M
example.
What is the purpose of the map() function? Provide
9 2M
a simple example.
Differentiate between filter() and reduce()
10 2M
functions in Python.
[Link] Essay Answer Questions Marks
1 Develop a Python program to process employee 8M
salary details using functions. The program
should accept the name, basic salary, and number
of years of experience of an employee. A function
should be defined to calculate the bonus based on
experience, where employees with more than 5
years of experience receive a 20% bonus and
others receive a 10% bonus. Another function
should compute the total salary including the
bonus. The program should display the employee
details along with the calculated total salary.
2 Implement a Python program to demonstrate the 8M
use of functions with multiple parameters, default
parameters, and keyword arguments. Define a
function to calculate the total cost of purchasing
items, where the function accepts the item price,
quantity, and an optional discount percentage
(default value 0). The function should compute
and return the final amount after applying the
discount. Demonstrate the function by calling it
using both positional and keyword arguments.
3 Design a Python program using arbitrary 8M
argument lists to process student marks. Define a
function that accepts a variable number of marks
using *args, calculates the total and average, and
returns the result. Extend the program to accept
student details using **kwargs and display the
complete information along with computed
results.
4 Develop a Python program to demonstrate scope 8M
rules. The program should define both global and
local variables and show how variables behave
inside and outside functions. Include examples to
illustrate the use of the global keyword and explain
how variable values change when modified within
a function.
5 Implement a Python program to demonstrate the 8M
use of higher-order functions. The program should
accept a list of integers from the user and perform
the following operations: use the map() function to
square each number, use the filter() function to
extract even numbers, and use the reduce()
function to compute the sum of all elements.
Display the results of each operation.
6 Develop a Python program that uses functions to 8M
process a list of numbers. The program should
define separate functions to find the maximum,
minimum, and sum of elements in the list. The
main program should call these functions and
display the results. Additionally, modify the
program to use a higher-order function to apply a
transformation (such as doubling each element) to
the list.
Module-4: Object Oriented Programming
[Link] Short Answer Questions Marks
Define Object-Oriented Programming (OOP). List
1 2M
any two features of OOP.
2 Define a class in Python? Give an example. 2M
3 Define object? How is an object created in Python? 2M
Differentiate between a method and a function in
4 2M
Python.
Explain attributes in a class? Distinguish between
5 2M
instance and class attributes.
Explain the different types of access specifiers in
6 2M
Python.
What is inheritance? Give an example of a base
7 2M
class and a subclass.
Define polymorphism in Python with a simple
8 2M
example.
9 What is method overriding in Python? 2M
Describe the purpose of the self-keyword in Python
10 2M
classes?
[Link] Essay Answer Questions Marks
1 Develop a Python program to manage student 8M
details using classes and objects. Define a class
Student with attributes such as name, roll
number, and marks. Include methods to accept
data and display student details. Extend the
program to calculate and display the grade based
on marks using appropriate conditions.
2 Write a Python program to demonstrate the use of 8M
class and instance attributes. Define a class
Employee with a class attribute representing the
company name and instance attributes such as
employee name and salary. Include methods to
display employee details and show how class
attributes are shared among all objects.
3 Design a Python program to demonstrate 8M
inheritance. Create a base class Person with
attributes such as name and age. Derive a
subclass Teacher that includes additional
attributes such as subject and salary. Implement
methods to display details of both classes and
show how the subclass accesses the base class
properties.
4 Develop a Python program to illustrate method 8M
overriding in inheritance. Create a base class
Shape with a method to calculate area. Derive
subclasses such as Rectangle and Circle that
override the area method based on their formulas.
Display the area for different shapes.
5 Write a Python program to demonstrate 8M
polymorphism using functions and objects. Define
multiple classes such as Dog, Cat, and Bird, each
having a method named sound(). Create objects of
these classes and demonstrate how the same
method name behaves differently for different
objects.
6 Design a Python program to demonstrate single 8M
inheritance. Create a base class Person with
attributes such as name and age. Derive a class
Employee from Person that includes additional
attributes such as employee ID and salary.
Implement methods to accept and display details,
and demonstrate how the subclass inherits and
utilizes the properties of the base class.
Module-5: File Handling
[Link] Short Answer Questions Marks
Define a file in Python? List different file modes
1 2M
used in file handling.
Explain the difference between text files and
2 2M
binary files in Python
Describe the purpose of open() function in Python?
3 2M
Write its syntax.
Differentiate between read(), readline(), and
4 2M
readlines() methods?
5 Explain Pandas Series? Give an example. 2M
Define a DataFrame in Pandas. How is it different
6 2M
from a Series?
How can a CSV file be read using Pandas? Write
7 2M
the syntax.
How do you write data from a DataFrame into a
8 2M
CSV file?
Explain indexing in a Pandas Series? Give an
9 2M
example.
Describe the purpose of head() and tail() methods
10 2M
in Pandas?
[Link] Essay Answer Questions Marks
1 Develop a Python program to perform file handling 8M
operations. The program should accept text input
from the user and write it into a file. After writing,
the program should read the contents of the file
and display them. Additionally, count and display
the number of lines, words, and characters
present in the file.
2 Implement a Python program to demonstrate 8M
different file modes. The program should create a
file, write data into it using write mode, append
additional data using append mode, and finally
read and display the complete contents of the file.
3 Design a Python program using Pandas to create a 8M
Series from a list of numbers. The program should
display the Series, perform basic operations such
as finding the sum and mean, and demonstrate
how to access elements using indexing.
4 Develop a Python program to create a DataFrame 8M
from a dictionary containing student details such
as name, age, and marks. The program should
display the DataFrame, calculate the average
marks, and identify the student with the highest
marks.
5 Design a Python program to read data from a CSV 8M
file using Pandas. The program should display the
first five and last five records, show the column
names, and compute basic statistics such as mean
and maximum values for numerical columns.
6 Implement a Python program to process data from 8M
a CSV file containing employee details. The
program should read the file into a DataFrame,
filter employees whose salary is above a given
threshold, and display the filtered results.
Additionally, the program should save the filtered
data into a new CSV file.
Module-6: Graphical User Interface
[Link] Short Answer Questions Marks
1 Define Tkinter? Mention its purpose in Python. 2M
List out the basic steps to create a simple Tkinter
2 2M
window.
Explain about a widget in Tkinter? Give any two
3 2M
examples.
Explain the purpose of the Label widget with an
4 2M
example.
5 Differentiate between Entry and Text widgets? 2M
6 Define a Button widget? How is it used in Tkinter? 2M
Differentiate between Checkbutton and
7 2M
Radiobutton.
8 Briefly describe Frame widget in Tkinter? 2M
List the different geometry managers in Tkinter
9 2M
and mention their purpose.
Define event handling in Tkinter? Name any two
10 2M
types of events.
[Link] Essay Answer Questions Marks
1 Develop a Python GUI application using Tkinter to 8M
create a simple user registration form. The form
should include widgets such as Label, Entry, and
Button to accept user details like name and age.
When the user clicks the submit button, the
entered details should be displayed on the window.
2 Implement a Python program using Tkinter to 8M
demonstrate the use of different widgets such as
Label, Button, Entry, Checkbutton, and
Radiobutton. The program should allow the user
to select options and display the selected values
when a button is clicked.
3 Design a Tkinter-based application to create a 8M
basic calculator that performs addition,
subtraction, multiplication, and division. The
application should accept user input through
Entry widgets and display the result when the
corresponding operation button is clicked.
4 Develop a Python program using Tkinter to 8M
demonstrate different geometry managers. The
program should arrange multiple widgets using
pack(), grid(), and place() and show how each
manager positions the widgets differently.
5 Implement a Tkinter program to create a Listbox 8M
that displays a list of items. The program should
allow the user to select an item from the list and
display the selected item when a button is clicked.
6 Design a Python GUI application using Tkinter to 8M
demonstrate event handling. The program should
respond to keyboard and mouse events such as
key press, mouse click, and mouse movement, and
display the corresponding event information on
the window.