0% found this document useful (0 votes)
21 views

Practical

Rhdfuvcvh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Practical

Rhdfuvcvh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program List For Practical Record

1. Write a Function LShift(Arr,n) in Python ,which accepts a list Arr of numbers and n is a numeric
value by which all elements of the list are shifted to left . Print the list Arr after shifting n
positions.
Sample Input Data of the List Arr =[10,20,30,40,12,11] ,n=2
Output : Arr=30,40,12,11,10,20]
2. Write a function EOReplace() in Python which accepts a List L of numbers .Thereafter ,it
increments all even numbers by 1 and decrements all odd numbers by 1.
Example:
If sample input data of the list is :
L=[10,20,30,40,35,55]
Output will be:
L=[11,21,31,41,34,54]
3. Write a Program to read text file Poem.txt line by line and display each word separated by a #.
4. Write a Program to read a text file Story .txt and display the number of vowels
/consonants/uppercase/lowercase characters in the file.
5. Write a Program to read a text file Poem.txt to count and print those lines that begin with ‘A’ or
‘a’ .
6. Write a Program to remove all the lines that contain the character 'a' in a file Poem.txt and write
it to another file named Temp.txt .
7. Consider a binary file Student.dat with record containing fields roll number ,name and
marks. Student record is in the form [Roll,Name,Marks].
a. Define a function WriteData() in which take input for a student record and write it into the
file .
b. Define a function SearchData() to search for a given roll number and display the name, if not
found display appropriate message.
c. Define a function DisplayData() to read all records from the file Student.dat and display
them.
d. Define a function UpdateMarks() to input a roll number and update the marks of the
respective student.
e. Define a function to search and display those records of students who scored above 75
percent from a binary file Student.dat .
8. Consider a binary file Employee.dat containing employee records. Employee record is in the
format [EmpCode,EmpName ,Salary]
a. Define a function AddRecord() to add an employee record into the file by taking user input.
b. Define a function DisplayRecord() to display the employee records that are earning more than
30000 salary.
9. Consider a CSV file User.csv Containing UserId and Password of various users and write
program code for the following.

a. Define a function WriteCSV() to create a CSV file User.CSV by entering user id and password
as user input.

b. Define a function ReadCSV() to read password for a given user id from USER.CSV file.

10. Write a Program in Python that defines and calls the following user defined functions:
(i) 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.

(ii) search()- To display the records of the furniture whose price is more than 10000.

11. Suresh has a list of items containing list of Integers. Help him to create a Python program with
separate user_defined functions to perform the following operations based on the list .
(i) PushPrime(list1) - To push all the even numbers from the list list1 into the stack.
(ii) Pop_element() - To pop and display elements from elements from the stack .Also
display ‘ Stack Empty’ message when there is no element in the stack .

12. Julie has created a dictionary containing names and marks as key value pairs of 6 students. Write a
program, with separate user defined functions to perform the following operations:

● Push the keys (name of the student) of the dictionary into a stack, where the corresponding
value (marks) is greater than 75.

● Pop and display the content of the stack.

For example: If the sample content of the dictionary is as follows:

R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}

The output from the program should be: TOM ANU BOB OM

13.A list contains following record of a customer: [Customer_name, Phone_number, City] Write the
following user defined functions to perform given operations on the stack named ‘status’:

(i) Push_element() - To Push an object containing name and Phone number of customers who live in
Goa to the stack

(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack Empty”
when there are no elements in the stack.

For example: If the lists of customer details are:

[“Gurdas”, “99999999999”,”Goa”] [“Julee”, “8888888888”,”Mumbai”]


[“Murugan”,”77777777777”,”Cochin”] [“Ashmit”, “1010101010”,”Goa”]

The stack should contain

[“Ashmit”,”1010101010”]

[“Gurdas”,”9999999999”]

The output should be:

[“Ashmit”,”1010101010”]

[“Gurdas”,”9999999999”]

Stack Empty

You might also like