Practical Term1
Practical Term1
For practical one program from each set (totally 3 programs) will be asked
SET - A
1. Write a program to accept a list of integers and do the following(without using predefined
function)
a. Sort using Bubble sort
b. Search a integer using Binary Search
2. Write a program to accept a list of integers and do the following
a. Sort using Insertion sort
b. Push the positive numbers to the beginning of the list
3. Write a program to accept a list of integers and do the following(without using predefined
function)
a. Swap the Alternate values of the list
(Example : Given list : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Resultant : 2, 1, 4, 3, 6, 5, 8, 7, 10, 9 )
b. Insert an integer when Data to insert is given by the user
4. Write a program to accept a list of integers and do the following(without using predefined
function)
a. Sort using Selection sort
b. Delete an integer when index to insert is given by the user
5. Write a program to accept a 2D tuple of integers of size M x N and do the following
a. Find Sum of each row and column
b. Find the sum of Left and Right diagonals if M = N
6. Write a program to accept a 2D tuple of integers of size M x N and do the following
a. Display the values in the boundary
b. Display the Upper and lower triangle
7. Write a program to accept a dictionary with Roll number as key, Name and Salary as values and
do the following
a. Find the total salary of all
b. Transfer the dictionary whose salary is above 10000 into the binary file of records and
display the file
8. Write a program to accept a Sentence from the user and do the following
a. find the frequency of each alphabet using the concept of dictionary
b. Find number of words, uppercase case alphabets, lower case alphabets, digits and other
characters
9. Accept a list of integers of Size N(EVEN) and do the following (Display all 4 arrays )
Tranfer to a 2D tuple of size N x N in the following format
o Given list [ 8, 2, 3 , 4 , 7 ]
o 2D tuple( ( 8 0 0 0 0 )
( 8 2 0 0 0)
( 8 2 3 0 0)
( 8 2 3 4 0)
( 8 2 3 4 7 ))
Tranfer to a 2D tuple of size N x N in the following format
o Given list [ 8, 2, 3 , 4 , 7 ]
o 2D tuple ( ( 0 0 0 0 8 )
(0 0 0 2 8)
(0 0 3 2 8)
(0 4 3 2 8)
(7 4 3 2 8 ))
Tranfer to a 2D tuple of size N x N in the following format
o Given list [ 8, 2, 3 , 4 , 7 ]
o 2D tuple ( ( 8 2 3 4 7 )
(0 2 3 4 0 )
(0 0 2 0 0)
(0 2 3 4 0)
(8 2 3 4 7 )
10. Write a program to accept 2 lists of size M and N. Merge the lists into single sorted list without
duplication. The resultant list must be get sorted while merging. Sort the given lists using any
sort. (Order will be given )
11. Write a program to accept a string (Sentence) from the user and do the following
a. Count number of words
b. Count number of “The” in the sentence
c. Find the frequency of each character given by the user
SET – B
1. Write a program to create a text file and do the following (ABC.TXT)
a. Count number of words, lines and characters
b. Transfer the Uppercase alphabets into a list
c. Display the contents of the file and list
3. Write a program to create two text files “ABC1.txt” and “ABC2.txt” and do the following
a. Merge the contents of both the files into “ABC.txt”.
b. Transfer the first and last word of each line of ABC1.txt into a list and display the list
1. Write a program to create a CSV file (Bookcode, Bookname, cost) and do the following
a. Display the contents of the file
b. Count number of records whose cost is below 100 rupee
2. Write a program to accept List of tuples with (Name, age, gender) and do the following
a. Transfer to the CSV file called ABC.CSV
b. Display the contents of the file
c. Count number of records whose age is below 10 from the CSV file
3. Write a Program in Python that defines and calls the following user defined functions:
ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each record
consists of a list with field elements as empid, name and mobile to store employee id, employee
name and employee salary respectively.
COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.
DISP() – To display the contents of the file
4. Write a Program in Python that defines and calls the following user defined functions:
Add() – To accept and add data of an employee to a CSV file ‘furdata.csv’. Each record consists
of a list with field elements as fid, fname and fprice to store furniture id, furniture name and
furniture price respectively.
Search()- To display the records of the furniture whose price is more than 10000.
Disp() – To display the contents of the file