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()