wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basic files

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

This command will open MyFile = open("MyText.txt")

a)

To read the file

b)

To append to the file

c)

To write to the file

2.

If I want to add to the end of a text file, I should:

a)

MyCipher = open("MyCipher.txt", "w")

b)

MyCipher = open("MyCipher.txt", "a")

c)

MyCipher = open("MyCipher.txt", "w+")

d)

MyCipher = open("MyCipher.txt", "s")

3.

Which of these will generate an error?

a)

MyCipher.write("writing")

b)

MyCipher..write(writing)

c)

MyCipher.write("writing",writing)

d)

MyCipher.readline()

4.

How do you close the file?

a)

MyFile = close()

b)

MyFile.close

c)

close = MyFile()

d)

MyFile.close()

5.

Why is it best to open a file with with in Python?

a)

It automatically closes the file

b)

Easier to read the code

c)

Better for binary files

d)

Closers to the pseudocode

6.

Which is the best type of loop to write a file in?

a)

While loop

b)

for loop

c)

repeat loop

7.

What command can you use to separate parts of a line?

a)

separate()

b)

split()

c)

divide()

d)

cut()

8.

What command can you use to send back data from a function?

a)

return

b)

sendback

c)

back

d)

print()

9.

How do you assign variables in pseudocode?

a)

b)

=

c)

==

d)

assign

10.

How do you CALL the function name in Python?

a)

name()

b)

def name()

c)

call name()

d)

GOTO name()