AI Prompt Builder

Generate a copy-paste ready prompt for ChatGPT, Claude, Gemini, or DeepSeek
Study Notes Prompt PPT Slides Prompt
Configure Prompt
Describe class, board, and ability level
Selected Lecture
Lecture #26
Text file reading writing searching and counting Theory part 1
Text file reading writing searching and counting
PYQ reference preview 18 included 0 excluded

Review every matched question before generating. Flag a wrongly categorised question to quarantine it from both study and PPT prompts until it is corrected in CBSE Paper Analyzer.

Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference 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 · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6556 · 2022 · 3 mark(s)
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
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6557 · 2022 · 3 mark(s)
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
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6301 · 2023 · 1 mark(s)
Assertion(A): xreadlines() reads all the lines from a text file and returns the lines along with newline as a list of strings. Reasoning (R): readline() can read the entire text file line by line without using any looping statements. (a) Both (A) and (R) are true and (R) is the correct explanation for (A). (b) Both (A) and (R) are true and (R) is not the correct explanation for (A). (c) (A) is true but (R) is false. (d) (A) is false but (R) is true.
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6116 · 2023 · 3 mark(s)
(a) Write the definition of a Python function named LongLines() which reads the contents of a text file named 'LINES.TXT' and displays those lines from the file which have at least 10 words in it. For example, if the content of 'LINES.TXT' is as follows : Once upon a time, there was a woodcutter He lived in a little house in a beautiful, green wood. One day, he was merrily chopping some wood. He saw a little girl skipping through the woods, whistling happily. The girl was followed by a big gray wolf. Then the function should display output as: He lived in a little house in a beautiful, green wood. He saw a little girl skipping through the woods, whistling happily.
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6117 · 2023 · 3 mark(s)
(b) Write a function count_Dwords() in Python to count the words ending with a digit in a text file "Details.txt". Example: If the file content is as follows : On seat2 VIP1 will sit and On seat1 VVIP2 will be sitting Output will be: Number of words ending with a digit are 4
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6314 · 2023 · 3 mark(s)
(b) Write a function RevString() to read a textfile "Input.txt" and prints the words starting with 'O' in reverse order. The rest of the content is displayed normally. Example : If content in the text file is : UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM Output will be : UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM (words 'OPEN' and 'OPERATING' are displayed in reverse order)
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6601 · 2023 · 3 mark(s)
Write a function, vowelCount() in Python that counts and displays the number of vowels in the text file named Poem.txt.
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6344 · 2024 · 1 mark(s)
Assertion (A) : If numeric data are to be written to a text file, the data needs to be converted into a string before writing to the file. Reason (R) : write() method takes a string as an argument and writes it to the text file. (A) Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A). (B) Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A). (C) Assertion (A) is true, but Reason (R) is false. (D) Assertion (A) is false, but Reason (R) is true.
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Included in reference ID 6620 · 2024 · 1 mark(s)
Write the missing statement to complete the following code: file = open("example.txt", "r") data = file.read(100) ____________________ #Move the file pointer to the beginning of the file next_data = file.read(50) file.close()
File Handling → Text file reading writing searching and counting · Concept U1_TEXT_FILE_OPERATIONS
Select a lecture and generate your AI prompt

Pick a lecture from the panel on the left, configure the board and student level, then click Generate Prompt. The result includes PYQ data, frequency analysis, exam trends, and a full 15-section teaching package request — ready to paste into any AI assistant.

ChatGPT Claude Gemini DeepSeek
PYQ Analysis
Frequency, marks & high-yield concepts
Lecture Flow
Exact time-allocation plan
15 Sections
From objectives to ranked exam questions
Export
Copy or download as .txt