Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python: Making a List

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is the correct way to create an empty list in Python?

a)

list = {}

b)

list = ()

c)

list = []

d)

list = empty

2.

Which of the following creates a list containing three fruits?

a)

fruits = ["apple", "banana", "cherry"]

b)

fruits = "apple", "banana", "cherry"

c)

fruits = {"apple", "banana", "cherry"}

d)

fruits = "apple" + "banana" + "cherry"

3.

What is the output of the following code? numbers = [] numbers.append(5) print(numbers)

a)

5

b)

[5]

c)

(5)

d)

{5}

4.

Which method is used to add a single element to the end of a list?

a)

add()

b)

insert()

c)

append()

d)

extend()

5.

What will be the content of colours after running the code below?

a)

red

b)

green

6.

What is the correct way to take a user’s input and add it to a list called names?

a)

input(names.append())

b)

name = input("Enter name: ") names.append(name)

c)

names.input().append("Enter name: ")

d)

append(input("Enter name: "))

7.

What will this code print?

a)

It prints only the last item entered.

b)

It prints both items entered as a list.

c)

It prints the word “items”.

d)

It shows an error.

8.

What does the following line of code do? my_list = list()

a)

Creates a list with one element called “list”.

b)

Creates an empty list.

c)

Deletes all lists.

9.

Which statement will add “orange” to this list correctly? fruits = ["apple", "banana"]

a)

append("orange", fruits)

b)

fruits.add("orange")

c)

fruits.append("orange")

d)

fruits.insert("orange")

10.

What will be the output of this code? my_list = [] user_input = "Python" my_list.append(user_input) print(my_list)

a)

A. Python

b)

B. ['user_input']

c)

C. [Python]

d)

D. ['Python']