Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python lists & file operations

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

How is a list created?

a)

a = 3, 5

b)

a = [3, 5]

c)

a = {3, 5}

d)

a = list

2.

Which python code means; assign 25 to the variable x2?

a)

25 = x2

b)

x2 = 25

c)

x2, 25

d)

25, x2

3.

a = [2, 5, 8, 1]

print("a[2]")

What is the output above?

a)

5

b)

8

c)

a[2]

d)

2

4.

list1 = ["hello", "hey", "hi"]

print(list1)

How many items will be printed?

a)

1

b)

2

c)

3

d)

0

5.

filename="example.txt"

with open(filename, "w") as myfile:

myfile.write("Pershendetje")

What happens here?

a)

a file called 'example' is being read

b)

a file called 'example' is created and some text is saved in it.

c)

The text in the 'example' file is assigned to a variable

d)

a variable called filename is created and it's value is printed on a file

6.

Write the code how to print the number of items of a list called 'mylist'?

(a)  

7.

What do you think about the difficulty level of Python?

a)

Very difficult

b)

A little difficult

c)

Average

d)

Not difficult

e)

Easy

8.

Select the one(s) which suits you.

a)

I can write codes in python

b)

I can create a list and let user add items to the list

c)

I can create a text file and print some text to it

d)

I can read some text from a file

9.

Write the python code to create an empty list and let the user add 15 values to it. Later print all items in separate lines.

4 lines
10.

Which statement is correct for adding the value 5 to a list called x?

a)

x.add(5)

b)

x.append(5)

c)

x.pop(5)

d)

x.insert(5)