Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python 2

Total questions: 23

Worksheet time: 11mins

Name
Class
Date
1.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
2.

The correct way to convert user input is:

a)

birth_year = number(input())

b)

birth_year = int(input())

c)

birth_year = (input(int))

d)

birth_year = int(input)

3.

What is the output for the following code?

a)

100

b)

50

c)

20

d)

130

4.

What is the purpose of variables in Python?

a)

Variables in Python are used to store data values for later use.

b)

Variables in Python are used for decoration purposes only.

c)

Variables in Python are used to perform mathematical operations.

d)

Variables in Python are used to confuse the programmer.

5.

How do you declare a variable in Python?

a)

variable_name = value

b)

variable_name : value

c)

variable_name = value =

d)

value = variable_name

6.

What are the different types of conditional statements in Python?

a)

when

b)

unless

c)

otherwise

d)

if, elif, else

7.

What is the syntax for an if statement in Python?

a)

if (condition) then

b)

if condition:

c)

if (condition):

d)

if condition then:

8.

How do you add comments in Python code?

a)

Use the '#' symbol to add comments in Python code.

b)

Use the '/* */' symbols to add comments in Python code.

c)

Use the '//' symbol to add comments in Java code.

d)

Use the '//' symbol to add comments in Python code.

9.

What will be the output of the following code?

a)
  • A) Greater

b)
  • B) Smaller

c)
  • C) Error

d)
  • D) None

10.

What will be the output of the following code?

a)
  • A) Greater

b)
  • B) Smaller

c)
  • C) Error

d)
  • D) None

11.

What will be the output of the following code?

a)
  • A) Greater

b)
  • B) Smaller

c)
  • C) Equal

d)
  • D) Error

12.

What will be the output of the following code?

a)
  • A) Greater

b)
  • B) Smaller

c)
  • C) Equal

d)
  • D) Error

13.

What will be the output of the following code?

a)
  • A) Yes

b)
  • B) No

c)
  • C) Error

d)
  • D) None

14.

What will be the output of the following code?

a)
  • A) Yes

b)
  • B) No

c)
  • C) Error

d)
  • D) None

15.

What will be the output of the following code?

a)
  • A) Yes

b)
  • B) No

c)
  • C) Error

d)
  • D) None

16.

What will be the output of the following code?

a)
  • A) Greater

b)
  • B) Equal

c)
  • C) Smaller

d)
  • D) Error

17.

What will be the output of the following code?

a)
  • A) Both True

b)
  • B) Only x is True

c)
  • C) Both False

d)
  • D) Error

18.

What will be the output of the following code?

a)
  • A) x is True, y is False

b)
  • B) Both True

c)
  • C) x is False

d)
  • D) Error

19.

What will be the output of the following code?

a)
  • A) Negative

b)
  • B) Zero

c)
  • C) Positive

d)
  • D) Error

20.

What will be the output of the following code?

a)
  • A) Negative

b)
  • B) Zero

c)
  • C) Positive

d)
  • D) Error

21.

What will be the output of the following code?

a)
  • A) Negative

b)
  • B) Zero

c)
  • C) Positive

d)
  • D) Error

22.

What will be the output of the following code?

a)
  • A) Even

b)
  • B) Odd

c)
  • C) Error

d)
  • D) None

23.

What will be the output of the following code?

a)
  • A) Even

b)
  • B) Odd

c)
  • C) Error

d)
  • D) None