Question types

Data File Handling question types

89 questions across 6 question groups — pick any mix to generate a Computer Science paper with step-by-step answer keys.

89
Questions
6
Question groups
5
Question types
Sample Questions

Data File Handling questions

One sample from each question group in this chapter. Select any group above to see the full set with answer keys.

Q 1M.C.Q1 Mark
What is the correct syntax of open() function?
  • A
    File = open(file_name[, access_mode][, buffering])
  •  File object = open(file_name [, access_mode][,buffering])
  • C
    File object = open(file_name)
  • D
     None of the above

Answer: B.

View full solution
Q 2M.C.Q1 Mark
Which of the following are the attributes related to a file object?
  • A
    Closed
  • B
    Mode
  • C
    Filename
  • $(a)$ and $(b)$

Answer: D.

View full solution
Q 3M.C.Q1 Mark
Which of the following functions do you use to write data in the binary format?
  • A
    Write 
  • B
    Output
  • Dump
  • D
    Send

Answer: C.

View full solution
Q 4M.C.Q1 Mark
Which of the following command is used to open a file "d:temp.txt" for writing in binary format only?
  • A
    fout = open("d:story.txt", "wb")
  • fout = open("d:temp.txt", "wb")
  • C
    fout = open(file = "d:temp.txt", "wb+")
  • D
     fout = open(file = "d:temp.txt", "wb+")

Answer: B.

View full solution
Q 5M.C.Q1 Mark
What does the method returns?
  • A
     Str
  • A list of lines
  • C
    List of single characters
  • D
    List of integers

Answer: B.

View full solution
Q 61 Marks Each1 Mark
A text file “Quotes.Txt” has the following data written in it:
Living a life you can be proud of
Doing your best
Spending your time with people and activities that are important to you
Standing up for things that are right even when it’s hard
Becoming the best version of you.
Write the output of the given program.

View full solution
Q 71 Marks Each1 Mark
Assume that file “tear.txt”, already contain “I love my India” in the file. What will be the output of the given program:

View full solution
Q 81 Marks Each1 Mark
Assume that file “tear.txt”, already contain “I love my India” in the file. What will be the output of the given program:

View full solution
Q 101 Marks Each1 Mark
Observe the following code and answer the questions that follow:

(i) What type (Text/Binary) of file is Mydata?
(ii) Fill the Blank 1 with statement to write “ABC” in the file “Mydata”.

View full solution
Q 112 Marks Each2 Marks
Write a function to read the content from the file “Story.txt”. The function will take a string as parameter and search the string into the file.
View full solution
Q 163 Marks Each3 Marks
Write a function delrecord() to delete the record form the binary file “employee”. The record should be delete on the basis of employee number.
View full solution
Q 173 Marks Each3 Marks
Write a function update () to update the record in the binary file “employee”, which consist of employee number, employee name and salary. The updation should be done on the basis of employee number entered by the user.
View full solution
Q 183 Marks Each3 Marks
Write a function search () to search a record in a binary file according to the employee number entered by the user. Also display the message “Record not found” in case record not found in the file.
View full solution
Q 203 Marks Each3 Marks
Write a function addrecord() a add new record to the binary file “employee” using list. The list should consist of employee number, employee name and salary.
View full solution
Q 215 Marks Each5 Marks
Krishna is confused in Python code given below. Please help him to answer the following questions.

(a) Which line in the above code check for capital letter?

(b) Which line in the above code read the file “story. txt”?

(c) Which line in the above code does not affect the execution of program?

(d) Which line is the above code coverts capital letter to small letter?

(e) Which line is the above code opens the file in write mode?

(f) Which line is the above code saves the data?

(g) Which line(s) is/are the part of selection statement.

(h) Which line(s) is/are used to close story1.txt?

View full solution
Q 225 Marks Each5 Marks
Krishna of class 12 is writing a program to read the details of Sports performance and store in the csv file “games.csv” delimited with a tab character. As a programmer, help him to achieve the task.

(a)Line 1 : Name the module he should import.

(b)Line 2 : To create an object to enable to write in the csv file.

(c)Line 3 : To store the data in list

(d)Line 4 : To write a record.

(e)Line 5 : To close the file.

View full solution
Q 235 Marks Each5 Marks
Dhruv Kumar of class 12 is writing a program to create a CSV file “Teacher.csv” which will store the teacher information entered by user. He has written the following code. As a programmer, help him to successfully execute the given task. Write appropriate statement / function/ code against fill ups.

View full solution
Q 245 Marks Each5 Marks
You are a student in CBSE School. Teacher has given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules:
(a)
View full solution
Q 255 Marks Each5 Marks
Mr. Mathew is a programmer, who has recently joined the company and given a task to write a python code to perform update operation in binary file (stud.dat) which contain admno (Admission No) and fee(Fee paid by student).

He has succeeded in writing partial code and has missed out certain statements, You as an expert of Python have to provide the missing statements.

(a)

View full solution
Q 264 Marks Each4 Marks
Aarti is new in python data-handling. Please help her to count the number of lines which begins with ‘W’ or ‘w’ in poem.txt.

(a) # Line 1 : To open file POEM.txt in read mode

(b) # Line 2 : To check first character of every line is ‘W’ or ‘w’.

(c) # Line 3 : To increase the value of count by 1.

(d) # Line 4 : To call the function count_poem.

View full solution
Q 274 Marks Each4 Marks
Write a function AverageColumn() which accepts csv file as parameter. It will print sum and average of each row. For example if marks.csv contain 50,60,70,80,90 70,60,50,60,80 50,60,70,80,90 Then OUTPUT will be Sum is : 350.0 Average is : 116.66666666666667 Sum is : 320.0 Average is : 106.66666666666667 Sum is : 350.0 Average is : 175.0
View full solution
Q 284 Marks Each4 Marks
Write a program to count no. of records in csv file and display the records in tabular form. Admno, Name, Eng, Hindi, Maths, Sci, Ssc 1101 1102 1103 1104 1105 Tejas Swati Sam Imran Heena 80 90 90 75 85 85 85 80 76 90 95 94 64 80 90 94 96 85 80 75 86 80 70
View full solution
Q 294 Marks Each4 Marks
Write a menu driven program to do the following option on binary file “Student”. The program should implement through list which contains student number, student name and marks. Student Menu ------------------ 1) Add New Student 2) Display student details 3) Search student 4) Update a Record 5) Delete a Record 6) Save & Quit
View full solution
Q 304 Marks Each4 Marks
Write a function delrecord() to delete the record form the binary file “student”. The record should be deleted on the basis of student number.
View full solution

Generate a Data File Handling paper free

Pick question groups from the list above, set marks and difficulty, and export a branded PDF with step-by-step answer keys. First 3 chapters free — no signup.

Download App