Python Practical Assignment
Python Practical Assignment
Instructions
• Answer all questions.
• Write clean and readable Python code.
• Add comments wherever required.
• Use proper variable names.
• Submit both .py file and output screenshots.
• Written document is practical copy too.
1. Write a Python program to print your name, roll number, and course name.
2. Write a program to take two numbers as input and print:
o Sum
o Difference
o Product
o Division
3. Write a program to check whether a number is even or odd.
4. Create variables of type int, float, string, and Boolean. Print their values and data types.
5. Take a number as input and convert it into:
o Integer
o Float
o String
6. Write a program to find the largest of three numbers.
7. Write a program to check whether a year is a leap year or not.
8. Write a program to calculate grades based on marks:
o 90 and above → A
o 75–89 → B
o 50–74 → C
o Below 50 → Fail
Type 2
Write a Python program to create an empty list using two different methods.
Print the type of the list in both cases.
Write a Python program to create:
• A homogeneous list
• A heterogeneous list
Display both lists.
Write a Python program to perform the following list operations:
• Append an element
• Insert an element at a specific position
• Remove an element
• Delete an element using index
Write a Python program to demonstrate list slicing.
Show slicing using:
• Positive index
• Negative index
Write a Python program to create a tuple and perform the following:
• Access elements using index
• Find the length of the tuple
• Convert the tuple into a list
Write a Python program to create a set and perform:
• Add element
• Remove element
• Union of two sets
• Intersection of two sets
Write a Python program to create a dictionary with student details.
Perform the following operations:
• Add a new key-value pair
• Update an existing value
• Delete a key
Write a Python program to iterate through a dictionary and print:
• Keys
• Values
• Key–Value pairs
Write a Python program to demonstrate the difference between remove(), pop(), and del
using a list.
Write a Python program that accepts multiple values from the user, stores them in a list,
then converts the list into:
• Tuple
• Set
and displays all three.
Type 3
1. Write a Python program to demonstrate slicing on a list using positive and negative
indexes.
Display at least three different slices.
2. Write a Python program to extract alternate elements from a list using slicing.
Also extract elements in reverse order.
3. Write a Python program to perform slicing on a string.
Print:
o First 5 characters
o Last 5 characters
o Middle characters
4. Write a Python program to slice a list and modify the sliced portion.
Show how changes affect (or do not affect) the original list.
5. Write a Python program to separate even-index and odd-index elements from a list using
slicing.
6. Write a Python program to reverse a list and a string using slicing.
Compare the outputs.
7. Write a Python program to copy a list using slicing ([:]).
Modify both lists and explain whether slicing creates a shallow or deep copy.
8. Write a Python program to slice a 2D list (list of lists) and extract specific rows and
columns.
9. Write a Python program that accepts a string from the user and uses slicing to check
whether it is a palindrome.
10. Predict the output of the following slicing operations and justify your answer:
data = [10, 20, 30, 40, 50, 60, 70]
print(data[1:6:2])
print(data[::-1])
print(data[-5:-1])
Submission Guidelines
• File name format: Python_Practical_Assignment_<YourName>.py
• Submission deadline: 9th Feb 2026.
End of Assignment