0% found this document useful (0 votes)
4 views2 pages

Questions 2 To 11

The document outlines a series of programming tasks in Python that involve file handling, data structures, and menu-driven interfaces. It includes creating and manipulating text files, binary files, and CSV files, as well as implementing stack operations for managing collections of countries and member details. Each task specifies functionalities such as counting words, updating records, and displaying contents based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Questions 2 To 11

The document outlines a series of programming tasks in Python that involve file handling, data structures, and menu-driven interfaces. It includes creating and manipulating text files, binary files, and CSV files, as well as implementing stack operations for managing collections of countries and member details. Each task specifies functionalities such as counting words, updating records, and displaying contents based on user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Q2: Create a text file “story.txt” using Python.

The file may contain trailing and leading white


spaces.
Write a Menu driven Python program:
(i) To display the size of the file after removing EOL characters, leading and trailing white
spaces and blank lines.
(ii) To read the file line by line and display each word separated by a #.
(iii) To count the number of “Me” or “My” words present in the above file.

Q3: Create a text file “sample.txt” using Python. The file could contain minimum 4 lines, and
few lines can start with the character ‘A’.
Write a Menu driven Python program:
(i) To display the number of lines in the file.
(ii) To display the number of words and white spaces in the file.
(iii) To display the number of lines starting with the letter ‘A’ or ‘T’.

Q4: Create a text file “sample.txt” using Python.


Write a menu driven Python program:
(i) Write a function vowelCount() in Python that counts and displays the number of vowels
in the text file.
(ii) Write a function in Python to read the text file and displays those lines which begin with
the word ‘You’.
(iii) Write a function remove_lowercase() that accepts two filenames as infile and outfile,
and copies all lines that do not start with a lowercase letter from infile to outfile.

Q5: Write a menu based Python program using Binary file concept:
(i) To add student details (rollno, sname and aggregate marks).
(ii) Search for a particular student and display his/her complete details. Otherwise, display
the appropriate message.
(iii) Update the student marks for the given rollno.
Display the contents of the file.

Q6:
Write a menu based Python program using Binary file concept:
(i) To store Employee details (Empno, Ename and salary) in a binary file.
(ii) Search for a particular Employee and display the complete details of the employee.
Otherwise, display the appropriate message.
(iii) Update the Employee salary for the given employee number.
(iv) Display the contents of the file.

Q7:
Write a menu based Python program using CSV File concept:
File name : “Phone.csv”
(i) Create CSV file and store Customerno, Cname, Address and Phoneno.
(ii) Search any customerno and display the complete details of the customer. If not, display
the appropriate message.
(iii) Update the address of the customer whose address needs to be changed.
Display the contents of the file.

Q8:
Write a menu-driven Python program to manage a collection of countries using a stack data
structure. The program should support the following operations:
1. Insert (Push): Add a country to the top of the stack.
2. Delete (Pop): Remove the country from the top of the stack.
3. Peek: Display the country currently at the top of the stack without removing it.
4. Display: Show all countries currently in the stack, from top to bottom.
5. Exit: Terminate the program

Q9:
Write a menu driven Python program to implement the operations insert, delete, peek and
display on stack containing member details as given in the following definition of members:
MemberNo integer
MemberName String
Age integer

Q10:
Write a Python Program to implement a Stack for the book details (bookno, bookname).
That is, each item node of the stack contains two types of information- a book number and
its name. Implement all the operations of Stack (push, pop, peek, display stack).

Q11: Write a menu driven program to solve the following problems:


(i) Input 5 words into list All. Create stack NoVowel with words that have no vowels. Pop
and display all from NoVowel then 'Empty Stack'.
(ii) Input 5 integers into Allvalues. Create stack only3_5 with values divisible by 3 or 5. Pop
and display all from only3_5 then 'EmptyStack'.

You might also like