wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Files

Total questions: 15

Worksheet time: 12mins

Name
Class
Date
1.

what is the sysntax of open() function in python

(a)  

2.

how many modes for opening a file?

(a)  

3.

By default the file is opened in text mode, but you can also open the file in binary mode. Which one of the following syntaxes opens the file in binary mode?

a)

x = bopen('demofile.txt')

b)

x = open('demofile.txt', 'b')

c)

x = open(b'demofile.txt')

4.

what is the use of readline() method?

(a)  

5.

The default opening mode when opening a file with the open() function is 'r' for 'reading'.

a)

True

b)

False

6.

After opening a file with the open() function, which method can be used to read the content?

a)

list()

b)

read()

c)

tuple()

7.

"w" - Write - will overwrite any existing content?

a)

True

b)

False

8.

In append mode cursor position will be at?

a)

starting

b)

ending

c)

middle

d)

none

9.

To remove a file you can import the os module, but which function removes the file?

a)

os.delete()

b)

os.drop()

c)

os.remove()

10.

Which os function can be used to delete an entire folder?

a)

os.delete()

b)

os.drop()

c)

os.remove()

11.

what are oops concepts?

(a)  

12.

what is the use of init() method in python?

(a)  

13.

what is use of self in python?

(a)  

14.

what is dictionary in python?

(a)  

15.

what is difference between discard() and remove() use in sets?

(a)