Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Grade 12

Total questions: 20

Worksheet time: 26mins

Name
Class
Date
1.

What is the correct syntax to create a list in Python?

a)

mylist = list()

b)

mylist = []

c)

mylist = {}

d)

Both A and B

2.

What is the output of the following code?

a)

0 1 2 3

b)

1 2 3

c)

0 1 2

d)

3 2 1

3.

Which of the following data types is mutable (can be changed)

a)

int

b)

float

c)

list

d)

str

4.

What is the output of:

a)

8

b)

3

c)

1

d)

Error

5.

What will this code print?

a)

3

b)

1

c)

0

d)

2

6.

What is the type of the value returned by input()?

a)

int

b)

float

c)

str

d)

Depends on the input

7.

Which of these statements will add an item to a list named fruits?

a)

fruits.append("apple")

b)

fruits.add("apple")

c)

fruits.insert("apple")

d)

add(fruits, "apple")

8.

Which keyword is used to test a condition in Python?

a)

test

b)

loop

c)

if

d)

for

9.

What will this code output?

a)

2 3 4 5

b)

2 3 4

c)

3 4 5

d)

1 2 3 4

10.

What is the result of:

a)

float

b)

int

c)

str

d)

list

11.

Which of these are valid Python data types?

a)

int

b)

list

c)

num

d)

bool

12.

Which of these are valid ways to print something to the screen?

a)

print("Hello")

b)

echo("Hello")

c)

print(5 + 2)

d)

display("Hello")

13.

Which of the following are examples of loops?

a)

for i in range(5):

b)

if x == 10:

c)

loop x times:

d)

for loop range(5)

14.

Which statements can be used to find the minimum in a list named scores?

a)

min(scores)

b)

print(min(scores))

c)

lowest(scores)

d)

findMin(scores)

15.

Write a Python statement to get input from the user and store it in a variable called name.

4 lines
16.

Write a for loop that prints the numbers 1 to 5.

4 lines
17.

Write a Python statement to create an empty list called grades.

4 lines
18.

If you have a list nums = [2, 7, 1, 8], write a line of code to display the smallest number.

2 lines
19.

What is the data type of the value "123" (with quotes)?

4 lines
20.

I am a sequence, yet I’m not a string.
I can hold numbers, words, or almost anything.
You can loop through me or find my length with ease.
Change one of my elements, and I’ll do it with peace.

What am I?

4 lines