Friday, 17 July 2026
Lecture 28 of 73 · Unit 1
Unit 1 ⏳ Pending
Unlocks at 05:00 PM, 17 Jul 2026

Text file reading writing searching and counting PYQ part 1

What We'll Learn

A quick overview of today's lecture

Text file reading writing searching and counting PYQ part 1 PYQ PRACTICE SCOPE: Text file reading writing searching and counting. Concept ID: U1_TEXT_FILE_OPERATIONS. Use only previous-year questions whose concept_ids include U1_TEXT_FILE_OPERATIONS.
Key things we'll cover
Text file reading writing searching and counting
PYQ references used by both prompts 9 included 0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6476 · 2021 · 1 mark(s)
Which of the following options can be used to read the first line of a text file Myfile.txt? a) myfile = open('Myfile.txt'); myfile.read() b) myfile = open('Myfile.txt','r'); myfile.read(n) c) myfile = open('Myfile.txt'); myfile.readline() d) myfile = open('Myfile.txt'); myfile.readlines()
File Handling → Text file reading writing searching and counting
Included ID 6477 · 2021 · 1 mark(s)
Assume that the position of the file pointer is at the beginning of 3rd line in a text file. Which of the following option can be used to read all the remaining lines? a) myfile.read() b) myfile.read(n) c) myfile.readline() d) myfile.readlines()
File Handling → Text file reading writing searching and counting
Included ID 6498 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Twinkle twinkle little star How I wonder what you are Up above the world so high Like a diamond in the sky What will be the output of the following code? myfile = open("Myfile.txt") data = myfile.readlines() print(len(data)) myfile.close() a) 3 b) 4 c) 5 d) 6
File Handling → Text file reading writing searching and counting
Included ID 6511 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Humpty Dumpty sat on a wall Humpty Dumpty had a great fall All the king's horses and all the king's men Couldn't put Humpty together again What will be the output of the following code? myfile = open("Myfile.txt") record = myfile.read().split() print(len(record)) myfile.close() a) 24 b) 25 c) 26 d) 27
File Handling → Text file reading writing searching and counting
Included ID 6513 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Honesty is the best policy. What will be the output of the following code? myfile = open("Myfile.txt") x = myfile.read() print(len(x)) myfile.close() a) 5 b) 25 c) 26 d) 27
File Handling → Text file reading writing searching and counting
Included ID 6514 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Culture is the widening of the mind and of the spirit. What will be the output of the following code? myfile = open("Myfile.txt") x = myfile.read() y = x.count('the') print(y) myfile.close() a) 2 b) 3 c) 4 d) 5
File Handling → Text file reading writing searching and counting
Included ID 6516 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Ek Bharat Shreshtha Bharat What will be the output of the following code? myfile = open("Myfile.txt") vlist = list("aeiouAEIOU") vc=0 x = myfile.read() for y in x: if(y in vlist): vc+=1 print(vc) myfile.close() a) 6 b) 7 c) 8 d) 9
File Handling → Text file reading writing searching and counting
Included ID 6517 · 2021 · 1 mark(s)
Suppose content of 'Myfile.txt' is: Twinkle twinkle little star How I wonder what you are Up above the world so high Like a diamond in the sky Twinkle twinkle little star What will be the output of the following code? myfile = open("Myfile.txt") line_count = 0 data = myfile.readlines() for line in data: if line[0] == 'T': line_count += 1 print(line_count) myfile.close() a) 2 b) 3 c) 4 d) 5
File Handling → Text file reading writing searching and counting
Included ID 6519 · 2021 · 1 mark(s)
Assume the content of text file, 'student.txt' is: Arjun Kumar Ismail Khan Joseph B Hanika Kiran What will be the data type of data_rec? myfile = open("Myfile.txt") data_rec = myfile.readlines() myfile.close() a) string b) list c) tuple d) dictionary
File Handling → Text file reading writing searching and counting
.txt