Test Index

CBSE Class 12 Computer Science 2023 Paper Compartment Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 27 of 35
Marks: +1, -0
(a) Write a function in Python that displays the book names having ‘Y’ or ‘y’ in their name from a text file “Bookname.txt”.
Example :
If the file ‘Bookname.txt’ contains the names of following books :
One Hundred Years of Solitude
The Diary of a Young Girl
On the Road
After execution, the output will be :
One Hundred Years of Solitude
The Diary of a Young Girl
OR
(b) Write a function RevString() to read a textfile “Input.txt” and prints the words starting with ‘O’ in reverse order. The rest of the content is displayed normally.
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(words ‘OPEN’ and ‘OPERATING’ are displayed in reverse order)
Advertisements
Go to Question: