wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in Python?

a)

Print("Hello World")

b)

P "Hello World"

c)

p ("Hello World")

d)

Print["Hello World"]

2.

Lists are used to store single item in a single variable.

a)

True

b)

False

3.

List items are indexed, the first item has index [1], the second item has index [2] etc.

a)

True

b)

False

4.

If you add new items to a list, the new items will be placed at the end of the list.

a)

True

b)

False

5.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

6.

 Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

nameList["4"]

7.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3

8.

If the list of vegetables is defined as:

vegetables = ["Potato", "Cucumber", "Lemon", "Tomato"]

Then what is the output of the following statements?

del vegetables[2]

print(vegetables)

a)

['Ptato', 'Cucumber', 'Tomato']

b)

['Ptato', 'Cucumber', 'Lemon', 'Tomato']

c)

None of these

9.

Which loop is used when you know the exact number of repetitions?

a)

While Loop

b)

For Loop

c)

Repeat Loop

10.

Which loop is known as condition-controlled loop?

a)

While

b)

For

c)

None of these

11.

The position of an element in the list in known as _________

a)

List

b)

Index

c)

Value

12.

What is the purpose of this program?

games = ["cricket", "hockey", "tennis"]

games[0] = "football"

a)

hockey will be replaced with football

b)

football will be added in the list

c)

hockey will be removed

13.

Which function is used to find the length of a list?

a)

Print( )

b)

Input( )

c)

len( )

14.

If the list has 5 elements, the index numbers go from --------

a)

0 to 4

b)

1 to 4

c)

1 to 5

15.

A program which does not crash is known as -----------

a)

Robust Program

b)

Strong Program

c)

Weak Program

16.

Validation is used to --------------

a)

Allow bad input

b)

Block bad input

c)

None of these

17.

If structure begins with ----------

a)

A logical test

b)

Bracket

c)

Both of these

18.

If the test is true in if...else, it means to -------

a)

show an error

b)

carry out the command

c)

Both of these

19.

Which of the following will ask you to input until the value matches the requirements of the program?

a)

For Loop

b)

If....else

c)

While Loop

d)

None of these

20.

What will be the output of these commands?

value = len("Python")

print(value) 

a)

6

b)

5

c)

4

d)

2