Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Ranges and Operators

Total questions: 17

Worksheet time: 9mins

Name
Class
Date
1.

What is the output of the following code

a)

Salary: 12000 Salary: 8000

b)

Salary: 8000 Salary: 12000

c)

The program failed with errors

2.

What is the output of the following code?

a)

The program executed with errors

b)

[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]

c)

[‘Jon’, ‘Kelly’, ‘Jessa’, ‘Scott’]

d)

[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]

3.

What is the output of the following code?

a)

True

True

b)

True

False

c)

False

True

d)

False

False

4.

What is the output of the following code?

a)

20

b)

30

c)

The program executed with errors

d)

24

5.

What is the output of the following code?

a)

 {‘Vicki’, ‘Jodi’, ‘Garry’, ‘Eric’}

b)

{‘Jodi’, ‘Vicki’, ‘Garry’, ‘Eric’}

c)

The program executed with error

6.

What is the output of the following code?

a)

py

b)

yn

c)

pyn

d)

yna

7.

Can we use the “else” block for for loop?

for example:

a)

No

b)

Yes

8.

What is the output of the following code?

a)

10

15

b)

25

125

c)

Error: invalid syntax

9.

Which operator has higher precedence in the following list

a)

% (Modulus)

b)

& (BitWise AND)

c)

** (Exponent)

d)

> (Comparison)

10.

What is the output of the following code?

name = "James"

print(name * 6)

a)

JamesJamesJamesJamesJamesJames

b)

JamesJamesJamesJamesJames

c)

Error: invalid syntax

d)

JaJaJamesJamesJamesmesmes

11.

What is the output of the following code?

a)

Jam

b)

dno

c)

maJ

d)

dnoB semaJ

12.

What is the output of the following code?

a)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]

b)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]

c)

The Program executed with errors

13.

What is the output of the following code?

a)

10 20

b)

10 20 30

c)

Error: invalid syntax

14.

What is the output of the following code?

a)

10, 11, 12, 13, 14,

b)

10, 11, 12, 13, 14, 15,

15.

What is the output of the following code?

a)

6

b)

33

c)

123

d)

Error. Mixing operators between numbers and strings are not supported

16.

What is the output of the following

a)

182.0

b)

37

c)

117

d)

The program executes with errors

17.

The in operator is used to check if a value exists within an iterable object container such as a list. Evaluate to True if it finds a variable in the specified sequence and False otherwise.

a)

True

b)

False