File Handling

File Handling

10th - 12th Grade

26 Qs

quiz-placeholder

Similar activities

Ch 3 Java Review-Strings and Math

Ch 3 Java Review-Strings and Math

9th - 12th Grade

21 Qs

Basic Linux Practice

Basic Linux Practice

12th Grade

23 Qs

GCSE Computer Science- 2.2 Programming Techniques

GCSE Computer Science- 2.2 Programming Techniques

9th - 11th Grade

25 Qs

COMPUTER

COMPUTER

11th - 12th Grade

21 Qs

Python File Handling

Python File Handling

10th Grade

22 Qs

AP CSA Review Unit 2

AP CSA Review Unit 2

9th Grade - University

22 Qs

2.2 Programming techniques

2.2 Programming techniques

10th - 11th Grade

24 Qs

Python Concepts Quiz

Python Concepts Quiz

11th Grade

21 Qs

File Handling

File Handling

Assessment

Quiz

Computers

10th - 12th Grade

Medium

Created by

Comp Sci

Used 5+ times

FREE Resource

26 questions

Show all answers

1.

FILL IN THE BLANK QUESTION

30 sec • 1 pt

___________ is a process of storing data into files and allows to performs various tasks such as read, write, append, search and modify in files.

Answer explanation

File Handling is the correct choice as it refers to the process of storing data in files and performing operations like reading, writing, appending, searching, and modifying data within those files.

2.

FILL IN THE BLANK QUESTION

30 sec • 1 pt

To close a file in a program _______ function is used.

Answer explanation

The correct function to close a file in a program is close(). This function is essential for releasing the resources associated with the file, ensuring that all data is properly saved and the file is no longer in use.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does this code myfile=open(“taxes.txt”) perform

opens the taxes.txt in default read mode.

opens the taxes.txt in default write mode.

opens the taxes.txt in default append mode.

opens the taxes.txt in default read and write mode.

Answer explanation

The code myfile=open("taxes.txt") opens the file 'taxes.txt' in the default read mode, which allows the program to read the contents of the file. Therefore, the correct choice is that it opens the taxes.txt in default read mode.

4.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

Mode in the following program to open file for writing in a mode where new data will be added at the end of old data

file =open("poem.txt","__")

r

w

a

r+

Answer explanation

The correct mode to open a file for writing where new data is added at the end of existing data is 'a' (append mode). This allows you to add content without deleting the old data, unlike 'w' which overwrites it.

5.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

Choose the correct statement to close a file stream named myfile:

myfile.terminate()

myfile.end()

myfile.close()

myfile.remove()

Answer explanation

The correct statement to close a file stream is 'myfile.close()'. This method properly releases the resources associated with the file, ensuring that all data is written and the file is no longer in use.

6.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What will be the output-

f=open('abc.txt','a')

text="xyz"

f.write(text)

f.close()

Writing into the file without erasing old content

Writing into the file by erasing old content

reading from the file without erasing old content

reading from the file by erasing old content

Answer explanation

The code opens 'abc.txt' in append mode ('a'), which allows writing new content without erasing existing content. Therefore, the correct choice is 'Writing into the file without erasing old content'.

7.

MULTIPLE CHOICE QUESTION

30 sec • 5 pts

What is the use of “a” in file handling?

Read

Write

Append

None of the mentioned

Answer explanation

In file handling, the mode 'a' is used to append data to the end of a file without overwriting existing content. This makes 'Append' the correct choice, as it specifically indicates adding new data to a file.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?