Search Header Logo

24-25 file handling

Authored by Deepti Gupta

Computers

11th Grade

Used 1+ times

24-25 file handling
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

27 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

To open a file c:\test.txt for reading, we should give the statement:

file1 = open(“c:\test.txt”,”r”)

file1 = open(“c:\\test.txt”,”r”)

file1 = open(file=”c:\test.txt”,”r”)

file1 = open(file=”c:\\s test.txt”,”r”)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

To open a file c:\ test.txt for writing, we should use the statement:

fobj = open(“c:\test.txt”,”w”)

fobj = open(“c:\\test.txt”,”w”)

fobj = open(file=”c:\test.txt”,”w”)

fobj = open(file=”c:\\test.txt”,”w”)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

To open a file c:\ test.txt for appending data, we can give the statement:

fobj = open(“c:\\test.txt”,”a”)

fobj = open(“c:\\test.txt”,”rw”)

fobj = open(file=“c:\test.txt”,”w”)

fobj = open(file=“c:\\ test.txt”,”w”)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements is/are true?

when we open a file for reading, if the file does not exist, an error occurs.

when we open a file for writing, if the file does not exist, a new file is created.

when we open a file for writing, if the file exists, the existing file is overwritten with the new file.

All of these

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Identify the error in the following code.

  1. 1. f = open ("workfile.txt', 'r+')

2. f.write('0123456789abcdef')

3. f.write('xyz8466')

4. f.close()

5. f.seek (0)

6. f.read()

Line 1

Line 2

Line 5

Line 6

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

To read the entire contents of the file as a string from a file object fobj, the command should be:

fobj.read(2)

fobj.read()

fobj.readline()

fobj.readlines()

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following snippet?

True

False

None

Error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?