Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Syntax Quiz

Total questions: 14

Worksheet time: 7mins

Name
Class
Date
1.

Which of the following is a data type that can have one of two values: True or False?

a)

float

b)

string

c)

integer

d)

boolean

2.

What symbol is used for modulo operation in Python?

a)

%

b)

&&

c)

**

d)

//

3.

What is used to create exponents in Python?

a)

^^

b)

exp

c)

**

d)

^^^

4.

Which of the following is the correct way to write a variable in Python?

a)

10 = my_variable

b)

my_variable: 10

c)

my variable = 10

d)

my_variable = 10

5.

What does the interpreter do in Python?

a)

Runs code line by line and checks for errors

b)

Creates comments

c)

Compiles the code

d)

Stores data

6.

What is the purpose of whitespace in Python?

a)

Used for variables

b)

Used to structure code

c)

Used for comments

d)

Used for data types

7.

What is the correct way to create a multi-line comment in Python?

a)

// comment

b)

/* comment */

c)

''' comment '''

d)

# comment

8.

What does the modulo operator return?

a)

The remainder from division

b)

The quotient from division

c)

The sum of two numbers

d)

The product of two numbers

9.

Which of the following is used to change the value of a variable?

a)

define

b)

reassign

c)

comment

d)

initialize

10.

What is the data type of the value 7.3 in Python?

a)

float

b)

int

c)

str

d)

bool

11.

Which of the following represents a string in Python?

a)

3.14

b)

True

c)

'Hello'

d)

7

12.

What is the data type of the value True in Python?

a)

bool

b)

str

c)

int

d)

float

13.

Which of the following is the correct syntax to calculate ten squared in Python?

a)

10 ** 2

b)

10 * 2

c)

10 ^ 2

d)

10 // 2

14.

What is the purpose of comments in Python?

a)

To define variables

b)

To store data

c)

To execute code

d)

To explain code