PROGRAMMING IN PYTHON
CIE-332P
Faculty Name: Mr.Anupam
Kumar Student Name: Vidyansh
Sinha Roll No.: 11014802722
Semester: 6th
Maharaja Agrasen Institute of Technology,
PSP Area,
Sector-22,Rohini,New Delhi-110086
EXPERIMENT 6
Write a program to see if a number is odd or even
using if- else statements
EXPERIMENT 7
Write a program to do grade classification using if-elif-
else statements
EXPERIMENT 8
Write a program to see if a number is divisible by 3
and 5
EXPERIMENT 9
Write a program to determine the triangle type
using if-elif- else statements
EXPERIMENT 10
Write a program to create a bill calculator using if-elif-
else statements
EXPERIMENT 11
Write a program for the game rock/paper/scissors
using if- elif-else statement
EXPERIMENT 12
Write a program to determine if a person is eligible
to vote or not
EXPERIMENT 13
Write a program to print even numbers using for
and while loop
EXPERIMENT 14
Write a program to find sum of n natural numbers
using for and while loop
EXPERIMENT 15
Write a program to find the factorial of the number
using for and while loop
EXPERIMENT 16
Write a program to check if the number is prime or
not using for and while loop
EXPERIMENT 17
Write a program to
print :- 1
121
12321
123432
1
EXPERIMENT 18
EXPERIMENT 19
Write a program to find the max and min element in a
list
EXPERIMENT 20
Write a program to calculate the sum and average of
all elements in a list.
EXPERIMENT 21
Write a Python program to count the occurrences of
a specific element in a list.
EXPERIMENT 22
Write a program to reverse a list.
EXPERIMENT 23
Write a Python program to check if a list is empty.
EXPERIMENT 24
Write a program to remove duplicates from a list and
display the unique elements.
EXPERIMENT 25
Write a Python program to merge two lists and sort
the resulting list in ascending order.
EXPERIMENT 26
Write a program to find the second largest number in a
list.
EXPERIMENT 27
Write a program to check if two lists have any common
elements.
EXPERIMENT 28
Write a Python program to rotate a list to the right by a
given number of positions.
EXPERIMENT 29
Write a program to flatten a nested list (e.g., [[1, 2], [3,
[4,
5]]] → [1, 2, 3, 4, 5]).
EXPERIMENT 30
Write a Python program to find all subsets of a given
list.
EXPERIMENT 31
Write a program to generate all permutations of a list.
EXPERIMENT 32
Write a Python program to find the longest increasing
subsequence in a list of numbers.
EXPERIMENT 33
Write a program to partition a list into sublists of
specified length.
EXPERIMENT 34
1. Write a Python program to create a dictionary
with three key-value pairs and print it.
2. Write a Python program to access the value of
a given key in a dictionary.
3. Write a Python program to add a new key-value
pair to an existing dictionary.
4. Write a Python program to remove a key
from a dictionary using the pop() method.
5. Write a Python program to check if a key
exists in a dictionary.
EXPERIMENT 35
1. Write a Python program to merge two
dictionaries into one.
2. Write a Python program to iterate through a
dictionary and print each key-value pair.
3. Write a Python program to find the key with
the maximum value in a dictionary.
EXPERIMENT 35
Write a Python program to count the occurrences of
each character in a string using a dictionary.
EXPERIMENT 36
Write a Python program to invert a dictionary (swap
keys and values).
EXPERIMENT 37
Write a Python program to sort a dictionary by its
values in ascending and descending order.
EXPERIMENT 38
Write a Python program to find the intersection of two
dictionaries (common keys with the same values).
EXPERIMENT 39
Write a Python program to convert two lists into a
dictionary (one as keys, the other as values).
EXPERIMENT 40
Write a Python program to group a list of dictionaries
by a common key.
EXPERIMENT 41
Write a Python program to implement a nested
dictionary where each key contains another
dictionary, and retrieve specific values
dynamically.
EXPERIMENT 42
Write a Python program to pretty-print a list of
dictionaries containing employee details (name, age,
department).
EXPERIMENT 43
Format and pretty-print a table displaying student
names and marks using string formatting.
EXPERIMENT 44
Create a Car class with attributes brand, model, and
year. Implement a method to display car details
EXPERIMENT 45
Design an Employee class with attributes name,
ID, and salary, and a method to give a
percentage-based salary increment.
EXPERIMENT 46
Write a Python program to reverse each word in a
given string while maintaining the word order.
EXPERIMENT 47
Implement a function to check whether a given string
is a valid password (at least 8 characters, contains
digits, uppercase, lowercase, and a special character)
EXPERIMENT 48
Write a Python program that handles ZeroDivisionError
and prompts the user to enter a valid denominator.
EXPERIMENT 49
Implement a function that opens a file and handles
FileNotFoundError if the file does not exist
EXPERIMENT 50
Create a Product class with attributes name, price, and
quantity. Handle exceptions when setting price (must
be positive) and use pretty printing to display multiple
products.
EXPERIMENT 51
Implement a function that takes a string as input,
stores each unique character as a key in a
dictionary with its frequency as the value, and
pretty-prints the dictionary. Handle TypeError if
input is not a string.
EXPERIMENT 52
EXPERIMENT 52
Develop a Student class with attributes name and
marks (list). Implement methods to calculate the
average marks and format the output using pretty
printing. Handle ValueError if marks contain invalid
data.
EXPERIMENT 53
1. Write a program to read a file and display its
content.
2. Write a program to write content to a file.
3. Write a program to check if a file exists.
4. Write a program to read a file line by line and print
each
EXPERIMENT 54
Write a program to combine the contents of two
text files into one.
EXPERIMENT 55
Write a program to save a dictionary using the
shelve module and then read it back.
EXPERIMENT 56
Write a program that renames a file using the os
module.
EXPERIMENT 57
Write a program to search for a file in a directory and
all its subdirectories using recursion.
EXPERIMENT 58
Write a program that copies a file from
one location to another, including
directories.
EXPERIMENT 59
Write a program that calculates and prints the size
of a file using os.path and os module.
EXPERIMENT 60
Create a program that reads data from a file and
then creates a visualization of that data using a data
visualization library.
EXPERIMENT 61
Create a program that uses a graphical user
interface (GUI) to allow the user to perform simple
calculations.
EXPERIMENT 62
Create a program that uses a networking library to
communicate with a server and retrieve data from it.
EXPERIMENT 63
Create a program that uses a machine learning library
to classify images based on their content.
EXPERIMENT 64
Create a program that uses regular expressions to find
all instances of a specific pattern in a text file.