Please refer to Computer Science For File Handling in Python Class 12 Computer Science Exam Questions provided below. These questions and answers for Class 12 Computer Science have been designed based on the past trend of questions and important topics in your class 12 Computer Science books. You should go through all Class 12 Computer Science Important Questions provided by our teachers which will help you to get more marks in upcoming exams.
Class 12 Computer Science Exam Questions File Handling in Python
Very Short Answer Type Questions :
Question. One row of CSV file can be considered as _______ in terms of database
Question. The writerow() function is a part of _________ module.
Question. A _____ function allows to write a single record into each row in CSV file.
Question. Which of the following is not a function of csv module? 1. readline() 2. writerow() 3. reader() 4. writer()
Question. CSV module allows to write multiple rows using ____________ function.
Question. Write the full form of CSV
Answer: Comma Separated value
Question. Write the functions required to handle CSV files.
Answer: To handle CSV files following function required:
Question. The default line terminator is \n in csv file.
Question. A _________ is a file format which stores records separated by comma.
Question. Write to ways to import a csv module.
Answer: 1. import csv 2. from csv import *
Short Answer Type Questions :
Question. Write a python program to copy file1.txt into file2.txt
Question. Which of the following function returns a list datatype
Question. Write a single loop to display all the contens of a text file file1.txt after removing leading and trailing WHITESPACES
for line in open(“file1.txt”):
Question. Observe the following code and answer the follow
(i)what type of file is mydata
(ii) Fill in the blank1 with statement to write “abc” in the file “mydata”
i) Text file
Question. Write a method in python to write multiple lines of text contents into a text file myfile.txt
f = open(“myfile.txt”,”w”)
line = input(“Enter line”)
choice = input(“Are there more lines”)
if choice == “N”:
Question. What would be the data types of variables data in following statements?
i) Data=f.read( )
Answer: a) string b)string c)string d)list
Question. A given text file data.txt contains :
What would be the output of following code?
Question. In which of the following file modes the existing data of the file will not be lost?
Answer: ab and a+b mode
Question. 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 a user defined function to display the total number of words present in the file.
I in z:
print(“Total number of words”,count)