Computer Science Assignment For Grade XII-2 19.04.2024
Computer Science Assignment For Grade XII-2 19.04.2024
Fortnightly Assignment
a)
b)
c)
d)
e)
f) Write a method/function DISPLAYWORDS() in python to read lines from a text file STORY.TXT, and display
those words, which are less than 4 characters.
g) Write a function RevText() to read a text file “ Input.txt “ and Print only word starting with ‘I’ in reverse order
.
Example: If value in text file is: INDIA IS MY COUNTRY Output will be: AIDNI SI MY COUNTRY
h) Write a function in python to count the number of lowercase alphabets present in a text file “BOOK..txt".
i) Write a user-defined function named Count() that will read the contents of text file named “Report.txt” and
count the number of lines which starts with either „I‟ or „M‟.
E.g. In the following paragraph, there are 2 lines starting with „I‟ or „M‟:
“India is the fastest growing economy. India is looking for more investments around the globe. The whole
world is looking at India as a great market. Most of the Indians can foresee the heights that India is capable
of reaching”
j) Write a function countmy( )in Python to read the text file “DATA.TXT” and count the number of times “my”
occurs in the file.
For example if the file “DATA.TXT” contains:
“This is my website. I have displayed my preferences in the CHOICE section.”
The countmy( ) function should display the output as: “my occurs 2 times”.
k) A text file “Quotes.Txt” has the following data written in it:
Living a life you can be proud of Doing your best Spending your time with people and activities that are
important to you Standing up for things that are right even when it’s hard Becoming the best version of you
Write a user defined function to display the total number of words present in the file.