Thanks to visit codestin.com
Credit goes to www.scribd.com

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

12 Cs Remedial Text File & Function

The document contains a remedial worksheet for computer science focused on text file handling and functions in Python. It includes tasks such as counting specific characters in a text file, identifying lines not starting with vowels, and calculating uppercase letters. Additionally, it presents several code snippets with questions regarding their outputs.

Uploaded by

Ahaan Kishore
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)
16 views2 pages

12 Cs Remedial Text File & Function

The document contains a remedial worksheet for computer science focused on text file handling and functions in Python. It includes tasks such as counting specific characters in a text file, identifying lines not starting with vowels, and calculating uppercase letters. Additionally, it presents several code snippets with questions regarding their outputs.

Uploaded by

Ahaan Kishore
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

12 computer science

Remedial Worksheet
Topic: Text File & Function
__________________________________________________________________
1. Write a function AMCount() in Python, which should read each character of a text file
STORY.TXT, should count and display the occurrence of alphabets A and M (including small
cases a and m too).

Example:
If the file content is as follows:
Updated information
As simplified by official websites
The AMCount() function should display the output as:
A or a: 4
M or m: 2

2. Write a method COUNTLINES() in Python to read lines from text file ‘TESTFILE.TXT’
and display the lines which are not starting with any vowel.

Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTLINES() function should display the output as:
The number of lines not starting with any vowel - 1

3. Write a function ETCount() in Python, which should read each character of a text file
“TESTFILE.TXT” and then count and display the count of occurrence of alphabets E and
T individually (including small cases e and t too).

Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
E or e: 6
T or t : 9

4. Write a program to count the number of upper case alphabets present in the text file
“Article.txt”.
5. What will be the output of the following snippets?
def changer(p,q=10):
p=p/q
q=p%q
print(p,"#",q)
return(p)
a=200
b=20
a=changer(a,b)
print(a,"$",b)

6. What will be the output of the following snippets?

def func(L):
Times=0
Alpha=""
Add=0
for c in range(1,6,2):
Times=Times+c
Alpha=Alpha+L[c-1]+"$"
Add=Add+L[c]
print(Times,Add,Alpha)

Data=["P",20,"R",10,"S",30]
func(Data)

7. What will be the output of the following snippets?

def check(n1=1,n2=2):
n1=n1+n2
n2+=1
print(n1,n2)
check()
check(2,1)
check(3)

8. What will be the output of the following snippets?

def interest(prnc,time=2,rate=0.10):
return(prnc*time*rate)

print(interest(6100,1))
print(interest(5000,rate=0.05))
print(interest(5000,3,0.12))
print(interest(time=4,prnc=5000))

You might also like