Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
7.9k views
in Computer by (15.9k points)

Your teacher has given you a method/function FilterWords() in python which read lines from a text file NewsLetter.TXT, and display those words, which are lesser than 4 characters. Your teachers intentionally kept few blanks in between the code and asked you to fill the blanks so that the code will run to find desired result. Do the needful with the following python code. 

def FilterWords():

c=0 

file=open('NewsLetter.TXT', '_____')  #Statement-1 

line = file._____ #Statement-2 

word = _____   #Statement-3 

for c in word: if _____:    #Statement-4 

print(c) _________   #Statement-5 

FilterWords()

i. Write mode of opening the file in statement-1? 

a. a 

b. ab 

c. w 

d. r 

ii. Fill in the blank in statement-2 to read the data from the file. 

a. File.Read() 

b. file.read() 

c. read.lines( ) 

d. readlines( ) 

iii. Fill in the blank in statement-3 to read data word by word. 

a. Line.Split()

b. Line.split() 

c. line.split() 

d. split.word()

iv. Fill in the blank in statement-4, which display the word having lesser than 4 characters. 

a. len(c) ==4 

b. len(c)<4 

c. len ( )= =3 

d. len ( )==3

v. Fill in the blank in Statement-5 to close the file. 

a. file.close() 

b. File.Close() 

c. Close() 

d. end()

Please log in or register to answer this question.

1 Answer

+1 vote
by (15.3k points)

i. Correct Answer: d. r

ii. Correct Answer: b. file.read()

iii. Correct Answer: c. line.split()

iv. Correct Answer: b. len(c)<4

v. Correct Answer: a. file.close()

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...