Python Practical Index: SR No Aim Date Marks /10 Sign Practical Set - 1
Python Practical Index: SR No Aim Date Marks /10 Sign Practical Set - 1
Sr Marks
Aim Date Sign
No /10
Practical Set – 1
1 Write a Python program to print “Hello World”.
2 Write a Python program to swap two variables using third variable.
3 Write a Python program to swap two variables without third variable.
4 Write a Python program to find square root of positive number.
5 Write a Python program to find area of a rectangle and circle.
6 Write a Python program to find sum of n natural numbers without loop.
7 Check various arithmetic operators of Python.
8 Write a Python program to check output of modulo operator.
Practical Set – 2
1 WAP to check whether entered number is even or odd.
2 WAP to find whether entered number is positive, negative or zero.
3 WAP to find roots of quadratic equations if roots are real.
4 WAP to check whether entered character is vowel or consonant.
5 WAP to find maximum of three numbers (nested if-else).
WAP to calculate the salary of an employee based on following conditions
(nested if-else):
1. if degree = B.E. and experience < 5 years, salary=30000
6
2. if degree = B.E. and experience >= 5 years, salary=40000
3. if degree = M.E. and experience < 5 years, salary=50000
4. if degree = M.E. and experience >= 5 years, salary= 60000
WAP to check whether entered input is character, digit or special symbol
7
using ladder if-else.
Practical Set – 3
1 WAP to find sum of first N numbers.
2 WAP to find sum of N scanned numbers.
3 Write a Python program to find N!.
4 Write a Python program to print Fibonacci series upto n terms.
5 WAP to find the reverse of given numbers (Example 2564-4652).
6 WAP to check whether entered number is prime or not.
WAP to print all even numbers between 1 to n except the numbers
7
divisible by 6.
Write a python program to check whether given number is Armstrong or
8
not.
Write a python program to check whether given number is Palindrome or
9
not.
WAP to print the following:
1) 1 2) * * * * *
12 ****
10 123 ***
1234 **
12345 *
Practical Set –4
Write a python program which covers all the methods (functions) of list.
1
Write a program to create an empty tuple, tuple with single value, tuple
5
with multiple values/collections and a tuple with different data types.
6 Check all the methods of tuple.
7 Write a program to find multiple items of a tuple.
Practical set-8 (Dictionary)
1 Write a Python script to add a key to a dictionary.
Write a Python script to print a dictionary where the keys are numbers
2
between 1 and 15 (both included) and the values are square of keys.
3 Write a Python script to check if a given key already exists in a dictionary.
4 Write a Python script to merge two Python dictionaries.
5 Write a Python program to remove a key from a dictionary.
6 Write a Python program to create a dictionary from two lists.
Write a Python program to check if all dictionaries in a list are empty or
7
not.
Practical Set –9 (I/O and File)
Write a python program to read the text file using read (), readlines() and
1
readline() methods.
Write a python program to read a file containing pairs of numbers in a file.
2 Create a file that contains the pairs of numbers as well as addition and
multiplication of the two numbers in the same line.
A text file contains a header line, few comments lines followed by actual
lines of data. Write a python program to create a function skip_header()
3
that skips the header and all the comment lines and prints only actual lines
of data.
Write a python program to create a function that returns smallest value
4
from the given text file.
Write the program-4 for a text file with missing values (missing values are
5
represented as hyphen (-)).
Practical Set –10 (Exception handling)
Implement the concept of multiple exceptions handling (IO error, Name
1
error, Value error)
Write a program to create customize exception for checking string length.
2
If string length is more than 2, then customize exception must be thrown.
Practical Set –11 (Classes and objects)
Create a class called Student with attributes names, enrollment number, spi
1 and cpi. Define getValues and printValues method to scan and print the
attributes of objects.
Create a class Book with title, list of authors, price and ISBN. Define
__init__() and __str()__ methods to initialize and print the objects declared
in the global scope. Also define two more methods: 1) noOfAuthors that
2
returns the number of authors of the given book, 2) __eq__() that returns if
the two books are equal or not when called with ‘==’ operator (compare
ISBN to check whether books are equal or not).
Define a class Teacher with attributes name ID. Inherit Principal and
Professor classes from the class Teacher with attribute noOfDept and
3
noOfClasses respectively. Define the methods to initialize and print the
objects of each class.
Practical Set –12 (Data structures using Python)
1 Implement Linear search and Binary search algorithms.
2 Implement selection sort and insertion sort algorithms.
3 Implement merge sort algorithm.
Write a Python program to create a Balanced Binary Search Tree (BST)
4 using given array elements where array elements are sorted in ascending
order.