Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
108 views

Python Practical Index: SR No Aim Date Marks /10 Sign Practical Set - 1

This document contains a Python practical index with 12 sets of programming exercises covering various Python concepts like variables, operators, conditional statements, loops, functions, lists, tuples, sets, dictionaries, classes, exceptions, file handling, and data structures. Some of the exercises include writing programs to print "Hello World", swap variables, find square roots, check if a number is even/odd, calculate salaries based on conditions, find maximum of numbers, perform arithmetic on matrices, create classes for students and books, and implement sorting algorithms.

Uploaded by

tester
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Python Practical Index: SR No Aim Date Marks /10 Sign Practical Set - 1

This document contains a Python practical index with 12 sets of programming exercises covering various Python concepts like variables, operators, conditional statements, loops, functions, lists, tuples, sets, dictionaries, classes, exceptions, file handling, and data structures. Some of the exercises include writing programs to print "Hello World", swap variables, find square roots, check if a number is even/odd, calculate salaries based on conditions, find maximum of numbers, perform arithmetic on matrices, create classes for students and books, and implement sorting algorithms.

Uploaded by

tester
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Python Practical Index

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

2 Write a Python program to append a list to the second list.


Write a python program to check whether the given list is palindrome or
3
not.
4 Write a python program to store strings in list and then print them.
Write a python program to print list of prime numbers upto N using loop
5
and else clause.
6 Write a Python program to multiply all the items in a list. 
7  Write a Python program to get the largest number from a list.
8  Write a Python program to find the second smallest number in a list.
Write a Python program to count the number of strings where the string
9 length is 2 or more and the first and last character are same from a given
list of strings.
Practical set-5 (LIST)
1 Write a Python program to remove duplicates from a list.
Write a Python program to find the list of words that are longer than n
2
from a given string.
Write a Python function that takes two lists and returns True if they have
3
at least one common member.
Write a Python program to print the numbers of a specified list after
4
removing even numbers from it. 
5 Write a Python program to add two matrices.
6 Write a Python program to transpose a given matrix.
7 Flatten a nested list structure.
Example: if list1 = [1, [2, 3], [4, 5, [6, 7] ] ] then try to convert it in 1-dimensional
[1, 2, 3, 4, 5, 6, 7]
8 Write a Python program to split a list every Nth element.

Practical Set –6 (lambda, map, reduce, filter, list comprehension)


1 Write a program to scan a list of integers using list comprehension.
2 Write a program to transpose a matrix using list comprehension.
3 Write a program to find the prime numbers in a specific range using filter.
4 Write a python program to make sum of particular range using reduce.
5 Write a python program to find maximum from a list using reduce.
Write a python program to find Armstrong number in a specific range
6
using map.
Write a python program to apply two functions (square and cube)
7
simultaneously on a specific range using map.
Write python programs using (i) map/filter and function (ii) map/filter and
lambda (iii) list comprehension
 Create a list to store the cube of all the elements in a given
list.
8
 Create a list of equivalent Celsius degree from Fahrenheit.
 Create a list that stores only positive numbers from given
list.
 Create a list that stores only alphabets from given list.
Practical set – 7 (Set and tuple)
Create a set of integers as follows:
 initialize the set directly
 initialize empty set and then add values
 from a list
1  from another set
 using range
 update an existing set using another set
 print the elements of set iteratively
 check the functionality of remove and discard
Create two sets of integers and find their difference, intersection, union
2 and symmetric difference. Also find subset and superset from these two.
Apply methods as well as operators for all operations.
Write a function called find_dups that takes a list of integers as its input
3 argument and returns a set of those integers that occur two or more times
in the list.
4 The following company details are given for analysis: customer acc no,
customer name, purchased product no, product category, unit price.
Marketing is interested in understanding customer purchase patterns. Find
the answers of following questions:
 How many customers have purchased bread?
 How many customers have purchased butter?
 How many customers have purchased bread and butter?
 Who has purchased bread but not butter?
 Which customers have purchased bread, butter and milk?
 Print the name of the most valuable customers who have
purchased all three items.

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.

You might also like