wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Review of Units 3 and 4

Total questions: 31

Worksheet time: 16mins

Name
Class
Date
1.

What is the result of the following expression in Python: `True and False`?

a)

True

b)

False

c)

None

d)

1

2.

Which of the following is a comparison operator in Python?

a)

`+`

b)

`==`

c)

`and`

d)

`#`

3.

Which of the following is a logical operator in Python?

a)

`*`

b)

`or`

c)

`!=`

d)

`//`

4.

What is the result of the expression `7 % 3` in Python?

a)

1

b)

2

c)

3

d)

4

5.

What will be the output of the following code?

x = 3.14159

print(round(x, 2))

a)

3.14

b)

3.15

c)

3.141

d)

3.142

6.

Which of the following is a valid variable name in Python?

a)

1variable

b)

variable_1

c)

variable-1

d)

variable 1

7.

What is the result of the following expression: `not (True or False)`?

a)

True

b)

False

c)

None

d)

0

8.

What does the following Python code do?

# This is a comment

print("Hello, World!")

a)

Prints "This is a comment"

b)

"Hello, World!"

c)

Prints nothing

d)

Causes an error

9.

What is the result of the expression `5 ** 2` in Python?

a)

10

b)

25

c)

7

d)

20

10.

Which of the following is a string operator in Python?

a)

`+`

b)

`*`

c)

`//`

d)

`and`

11.

What will be the output of the following code?

x = 10

y = 5

if x > y:

print("x is greater than y")

else:

print("x is not greater than y")

a)

x is greater than y

b)

x is not greater than y

c)

Error

d)

No output

12.

Which of the following is not a comparison operator in Python?

a)

`<=`

b)

`!=`

c)

`<>`

d)

`==`

13.

What is the result of the following expression: `not False`?

a)

True

b)

False

c)

None

d)

0

14.

What will be the output of the following code?

x = 4

y = 2

print(x // y)

a)

2.0

b)

2

c)

1

d)

0

15.

Which of the following is a valid comment in Python?

a)

`// This is a comment`

b)

`/* This is a comment */`

c)

`# This is a comment`

d)

``

16.

What is the result of the following expression: `10 / 3`?

a)

3

b)

3.33

c)

3.3333333333333335

d)

3.0

17.

What will be the output of the following code?

x = "Hello"

y = "World"

print(x + " " + y)

a)

HelloWorld

b)

Hello World

c)

Hello

d)

World

18.

What is the result of the following expression: `5 >= 5`?

a)

True

b)

False

c)

None

d)

0

19.

What will be the output of the following code?

x = 3.7

print(round(x))

a)

3

b)

4

c)

3.7

d)

Error

20.

Which of the following is a mathematical operator in Python?

a)

`and`

b)

`or`

c)

`+`

d)

`==`

21.

What is the result of the following expression: `not (3 > 5)`?

a)

True

b)

False

c)

None

d)

0

22.

What will be the output of the following code?

x = 10

y = 3

print(x % y)

a)

1

b)

2

c)

3

d)

0

23.

Which of the following is a valid way to declare a variable in Python?

a)

`int x = 5`

b)

`x = 5`

c)

`declare x = 5`

d)

`var x = 5`

24.

What is the result of the following expression: `4 != 4`?

a)

True

b)

False

c)

None

d)

0

25.

What will be the output of the following code?

x = 2

y = 3

print(x ** y)

a)

6

b)

8

c)

9

d)

5

26.

What is the result of the following expression: `not True`?

a)

True

b)

False

c)

None

d)

0

27.

What will be the output of the following code?

x = 5

y = 10

if x < y:

print("x is less than y")

else:

print("x is not less than y")

a)

x is less than y

b)

x is not less than y

c)

Error

d)

No output

28.

What is the result of the following expression: `7 <= 7`?

a)

True

b)

False

c)

None

d)

0

29.

Which of the following is not a logical operator in Python?

a)

`and`

b)

`or`

c)

`not`

d)

`==`

30.

What is the result of the following expression: `8 // 3`?

a)

2.666

b)

2

c)

3

d)

2.0

31.

What will be the output of the following code?

x = "Python"

y = "Programming"

print(x + " " + y)

a)

PythonProgramming

b)

Python Programming

c)

Python

d)

Programming