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

Python Project

1. The document provides examples of Python functions to perform various operations related to files and data structures like stacks. 2. Functions include incrementing/decrementing even/odd numbers in a list, pushing/popping customer names from a stack, pushing vehicle names to a stack, creating/reading/reversing text in a file, getting file size, searching/modifying records in a binary file, deleting records from a binary file, counting words/lines in a file. 3. The examples demonstrate how to define functions, open/write/read files, manipulate lists and stacks in Python.

Uploaded by

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

Python Project

1. The document provides examples of Python functions to perform various operations related to files and data structures like stacks. 2. Functions include incrementing/decrementing even/odd numbers in a list, pushing/popping customer names from a stack, pushing vehicle names to a stack, creating/reading/reversing text in a file, getting file size, searching/modifying records in a binary file, deleting records from a binary file, counting words/lines in a file. 3. The examples demonstrate how to define functions, open/write/read files, manipulate lists and stacks in Python.

Uploaded by

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

PYTHON

1. WAF EOREPLACE() WHICH ACCEPTS a list L of numbers. The function is


supposed to increment all even numbers by 1 and decrements all odd numbers
by 1.

output:

1|Page
2.
A list contains following record of a customer : [Customer_name, Room_type]
Write the following user defined functions to perform given operations on the
stack named ‘Hotel’ :

(i) Push_Cust() : To push customer names of those customers who are


staying in “Delux’ Room type.

(ii ) Pop_Cust() : To pop the names of customers from the stack and
display them. Also, display “Underflow” when there are no customers In the stack.

output:

2|Page
3.WAF Push(Vehicle) where, Vehicle is a dictionary containing details of vehicles -
{Car_name:Maker}. The function should push the name of car manufactured by
‘TATA’ to the stack.

output:

3|Page
4.WA function to create a file and put some text to it. Write another function that reads
this file and print the file contents in reverse.

output:

4|Page
5.WA function to create a file and enter some lines in it. Write another function to
return the size of file in bytes

output:

5|Page
6.WAF to enter student records [rno,name,age] in a binary file. Also write a function to
search for a particular roll number in the file.

output:

6|Page
7.WAF to enter student records {“rno”: rno,”name”:name ,”age”: age] in a binary file.
Also write a function to modify age for a particular roll number in the file.

output:

8.WAF to enter student


records in a binary file. Also
write a function to delete record
of a particular roll number in

7|Page
the file.

output:

9.Write a function to create a file and enter some lines in it. Write

8|Page
another function to return the number of words in the file.

output:

9|Page
10.WA function to create a file and enter some lines in it. Write another function to
return the number of lines that begin with a vowel

output:

10 | P a g e
11.Write a function to create a file and enter some lines in it. Write
another function to print number of words in each line.

output:

11 | P a g e

You might also like