wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Operators in Python

Total questions: 17

Worksheet time: 9mins

Name
Class
Date
1.

From logical operators

a)

<<

b)

is not

c)

not in

d)

not

2.

From assignment operators

a)

>>=

b)

==

c)

is

d)

in

3.

From arithmetic operators

a)

/=

b)

//

c)

and

d)

&

4.

From comparison operators

a)

>>

b)

>=

c)

=

d)

is

5.

From identity operators

a)

==

b)

in

c)

is

d)

=

6.

From membership operators

a)

=

b)

not in

c)

is

d)

!=

7.

From bitwise operators

a)

is not

b)

-

c)

not

d)

~

8.

 xy x^{y\ }  

a)

x^^y

b)

x^y

c)

x**y

d)

x pow y

9.

10%3

a)

3

b)

1

c)

9

d)

10

10.

10//3

a)

3

b)

3.3

c)

0.3

d)

3.0

11.

x = x ^ 3 can also be written as

a)

x = x pow 3

b)

x = x ** 3

c)

x = x XOR 3

d)

x ^= 3

12.

the output of: x >= y

a)

Adjust x so that it is greater than or equal y

b)

True if x is greater than or equal y

c)

x is shifted y bits to the right

d)

False if x equals y in value

13.

x = 5

print(not(x > 3 and x < 10))

a)

not(x > 3 and x < 10)

b)

True

c)

False

d)

syntax error

14.

What is the output of:

b=2

c=2

print(b is c)

c +=2

print(b is c)

a)

False

False

b)

False

True

c)

True

False

d)

True

True

15.

What is the output of:

l1 = [1, 2, 3]

l2 = l1

l1[0] = 7

print (l1)

print (l2)

print (l1 is l2)

a)

[7, 2, 3]

[7, 2, 3]

True

b)

[7, 2, 3]

[0, 2, 3]

True

c)

[7, 2, 3]

[7, 2, 3]

False

d)

[7, 2, 3]

[0, 2, 3]

False

16.

What is the output of:

x = ["apple", "banana"]

print("banana" in x)

a)

1

b)

True

c)

False

d)

2

17.

What is the output of:

print (7&8)

print (7|8)

print (7^8)

print (7>>3)

a)

0

15

15

0

b)

0

15

15

224

c)

0

15

0

0

d)

0

0

15

0