Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Operators in Python

Total questions: 43

Worksheet time: 22mins

Name
Class
Date
1.

print(7//2)

a)

2

b)

3

c)

4

2.

print(9>2 and 6<=6)

a)

TRUE

b)

FALSE

3.

print(8!=8)

a)

TRUE

b)

FALSE

4.

print(2**3)

a)

6

b)

12

c)

8

5.

print((15%4))

a)

4

b)

5

c)

3

6.

print("3"+"3")

a)

33

b)

6

c)

INVALID OUTPUT

7.

print(not (0<1))

a)

TRUE

b)

FALSE

c)

TYPE ERROR

8.

print(2%2==0 or 3%2==0)

a)

TRUE

b)

FALSE

c)

INVALID OUTPUT

9.

print(5+8*2)

a)

26

b)

21

c)

169

10.

print(4+"2")

a)

6

b)

42

c)

TYPE ERROR

11.

What is the value of the expression 100 / 25?

a)

4

b)

4.0

c)

"4.0"

d)

'4.0'

12.

x = 5

y = 3


print(x == y)

a)

True

b)

False

13.

x = 5

y = 3


print(x != y)

a)

True

b)

False

14.

x = 5


x%=3


print(x)

a)

2

b)

2.0

c)

3

d)

3.0

15.

From logical operators

a)

<<

b)

is not

c)

not in

d)

not

16.

From assignment operators

a)

>>=

b)

==

c)

is

d)

in

17.

From arithmetic operators

a)

/=

b)

//

c)

and

d)

&

18.

From comparison operators

a)

>>

b)

>=

c)

=

d)

is

19.

From identity operators

a)

==

b)

in

c)

is

d)

=

20.

From membership operators

a)

=

b)

not in

c)

is

d)

!=

21.

From bitwise operators

a)

is not

b)

-

c)

not

d)

~

22.

xy x^{y\ }  

a)

x^^y

b)

x^y

c)

x**y

d)

x pow y

23.

10%3

a)

3

b)

1

c)

9

d)

10

24.

10//3

a)

3

b)

3.3

c)

0.3

d)

3.0

25.

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

26.

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

27.

x = 5

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

a)

not(x > 3 and x < 10)

b)

True

c)

False

d)

syntax error

28.

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

29.

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

30.

print(5+8*2)

a)

26

b)

21

c)

169

31.

Look at the following code:

age = "23"

age = age + 1

print (age)


What is the result of this code?

a)

23

b)

24

c)

23 + 1

d)

an error message

32.

Look at the following code:

age = input ("What is your age? ")

age = age + 1

print (age)


If the user inputs 23, what is the result of the code?

a)

23

b)

24

c)

age

d)

an error message

33.

Look at the following code:

age = int(input ("What is your age? "))

age = age + 1

print (age)


If the user inputs 23, what is the result of the code?

a)

23

b)

24

c)

age

d)

an error message

34.

Look at the following code:

age = input ("What is your age? ")

age = int(age) + 1

print (age)


If the user inputs 23, what is the result of the code?

a)

23

b)

24

c)

age

d)

an error message

35.

Look at the following code:

age = input ("What is your age? ")

age = int(age + 1)

print (age)


If the user inputs 23, what is the result of the code?

a)

23

b)

24

c)

age

d)

an error message

36.

Look at the following code:

Length = 50

Width = 30

Area = Length * Width

print (Area)


What is the result of this code?

a)

Area

b)

50

c)

150

d)

an error message

37.

Look at the following code:

Length = 50

Width = 30

Area = L * W

print (Area)


What is the result of this code?

a)

Area

b)

50

c)

150

d)

an error message

38.

Look at the following code:

L = 50

W = 30

Area = L * W

print ("Area")


What is the result of this code?

a)

Area

b)

50

c)

150

d)

an error message

39.

Who developed python?

a)

Ritchie

b)

Bill gates

c)

Guido van Rossum

d)

Sunder

40.

In Python script editor, the errors will be shown in ----- color in the IDLE window?

a)

green

b)

black

c)

red

d)

orange

41.

Which is known as simple assignment operator?

a)

==

b)

=

c)

+=

d)

#

42.

Python uses ------ to define program blocks.

a)

whitespace

b)

delimiter

c)

escape sequence

d)

curly braces

43.

Which function accepts all data as string or characters but not as numbers?

a)

int()

b)

output()

c)

input()

d)

print()