wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python End of Topic Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

Which arithmetic operator will you use in the following program to multiply 10 by 5 and print the result?

print(10 _ 5)

a)

×

b)

/

c)

*

d)

**

2.

What will be the output of this program?

a)

210

b)

Syntax error

c)

210 30

d)

None of the above

3.

When a user inputs an answer, it should be stored in a suitably named ...?

a)

file

b)

variable

c)

data type

d)

list

4.

The PIN code is a six-digit code used by the Indian Postal Department.

What is the data type of the variable 'x' if it stores this code as x = "462016"?

a)

int

b)

string

c)

float

d)

number

5.

Given the list color_list = ["Red", "Blue", "Green", "Black"], what will be the output of print(color_list[1], color_list[3])?

a)

Red Green Black

b)

Blue Black

c)

Blue Black Syntax Error

d)

Blue Black IndexError: list index out of range

6.

Which of the following options will output 'HELLO, WORLD!' when the variable a is set to "Hello, World!"?

a)

a.upper()

b)

print(a.upper)

c)

a.upper()

d)

print(a.upper())

7.

What will be the output of this program?

a)

Pass

b)

Enter your score

c)

It will throw a syntax error

d)

Fail

8.

Which of the following options has the correct syntax for defining a list in Python?

a)

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

b)

mylist = [apple, banana, cherry]

c)

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

d)

mylist = ["apple", "banana" ; "cherry"]

9.

What is the purpose of the input() function in Python?

a)

Ask the user a question and receive input

b)

It is a conditional statement

c)

All of the above

d)

Convert user input to uppercase

10.

What will be the output of the following program?

x = 13
print(x)
x = "Jacob"

a)

13

b)

Jacob

c)

It will throw an error

d)

First 13 and then "Jacob" will be outputted

11.

What will be the output of the following code snippet?

# Define a list of fruits fruits = ["apple", "banana", "cherry"]
# Print the first and third elements of the list print(fruits[0], fruits[2])

a)

apple banana

b)

banana cherry

c)

IndexError: list index out of range

d)

apple cherry

12.

In Python, which function is used to convert a string to all lowercase letters?

a)

downcase()

b)

lower()

c)

lowercase()

d)

toLowerCase()

13.

What is the data type of the variable 'y' in the following code snippet?

y = 3.14

a)

int

b)

string

c)

float

d)

double

14.

What will be the output of the following code snippet?
numbers = [1, 2, 3, 4, 5]
print(numbers[1] + numbers[3])

a)

3

b)

5

c)

7

d)

6

15.

Which function is used to determine the number of elements in a list in Python?

a)

size()

b)

length()

c)

count()

d)

len()