wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Operators

Total questions: 35

Worksheet time: 2hrs 45mins

Name
Class
Date
1.

Which of these is not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

2.

What is the output of the following code :

print 9//2

a)

4.5

b)

4.0

c)

4

d)

Error

3.

Who developed the Python language?

a)

Zim Den

b)

Guido van Rossum

c)

Niene Stom

d)

Wick van Rossum

4.

Which one of the following is the correct extension of the Python file?

a)

.python

b)

.p

c)

.py

d)

None of these

5.

Which of the following declarations is incorrect?

a)

_x = 2

b)

__x = 3

c)

__xyz__ = 5

d)

None of these

6.

Which of the following declarations is incorrect in python language?

a)

xyzp = 5,000,000

b)

x y z p = 5000 6000 7000 8000

c)

x,y,z,p = 5000, 6000, 7000, 8000

d)

x_y_z_p = 5,000,000

7.

What will be the output of this statement?

>>>"a"+"bc"

a)

a+bc

b)

a bc

c)

abc

d)

a

8.
What is the output from the following code?print ("hello world")
a)
Hello World
b)
hello world
c)
print hello world
9.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
10.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
11.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

12.
What would amount equal in this piece of code:

amount = 2 + 5 * 2
a)
12
b)
9
c)
14
d)
5
13.

What is the output of range(1,10)

a)

0123456789

b)

123456789

c)

1 to 10

d)

012345

14.

Choose the correct declaration of a float variable with the value 3.14

a)

pi = "3.14"

b)

pi = int(3.14)

c)

pi = 3.14

d)

float pi = 3.14

15.

What is the final result of the expression 4 + 5 * 3?

a)

27

b)

12

c)

19

d)

21

16.

What is the final result of the expression 7 / 3 + 6?

a)

0

b)

8.33333333

c)

8

d)

.777777777778

17.

What does the following code print?

x = 3.4

y = 1

print int(x)

print x + y

a)

3.4

4.4

b)

3

4.4

c)

3

4

d)

The code causes an error

18.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

That is not a valid Python expression.

19.

What is the operator below called?

%

a)

Exponent

b)

Modulus

c)

Divide

d)

Percent

20.

print(9//3,9/3)

a)

3 3.3

b)

3.3 3

c)

3.0 3.3

d)

3.3 3.3

21.

Valid operation?

a)

'2'-'1'

b)

'third'*'2'

c)

'sum'**3

d)

"2"+"1"

22.

What is the output of this expression, 3*1**3?

a)

3

b)

21

c)

9

d)

33

23.

print(1.1+2.2==3.3)

a)

True

b)

False

c)

Error

d)

3.3

24.

Suppose the following statements are executed:

a = 100 b = 200

What is the value of the expression a and b?

a)

200

b)

100

c)

0

d)

False

25.

What is the output of “hello”+1+2+3 ?

a)

hello123

b)

hello

c)

Error

d)

hello6

26.

str1 = "My salary is 7000"; str2 = "7000" print(str1.isdigit()) print(str2.isdigit())

a)

False True

b)

False False

c)

True False

d)

True     True

27.

print(-18//-2)

print(18//2)

print(18/2)

print(18%2)

print(str(18/2))

find output

a)

9.0

9

9.0

0

9.0

b)

9

9

9.0

0

"9.0"

c)

9

9

9.0

0

9.0

d)

9

9

9.0

0

90

28.

x = 10

y = 50

if x ** 2 > 100 and y < 100:

print(x, y)

find output

a)

NONE

b)

Error

c)

10,50

d)

100

29.

4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators?a = 4

b = 11

print(a | b)

print(a >> 2)

a)

15

0

b)

0

15

c)

15

1

d)

1

15

30.

y = 10

x = y += 2

print(x)

a)

12

b)

10

c)

0

d)

Error

31.

print(int(12.53))

print(round(12.53))

print(round(12.36,1))

a)

13

12

12.4

b)

12

13

12.4

c)

12

13

12.3

d)

error

32.

Single line comment Symbol?

a)

//

b)

/

c)

$

d)

#

33.

Choose the correct function to get the character from ASCII number

a)

 ascii(number)

 

b)

 char(number)

 

c)

chr(number)

d)

ord(number)

34.

str1 = 'Welcome'

print (str1[:6] + ' PYnative')

a)

Welcome PYnative

 

b)

WelcomPYnative

 

c)

Welcom PYnative

 

d)

WelcomePYnative

35.

The function pow(x,y,z) is evaluated as:

a)

(x**y)**z

b)

(x**y) / z

c)

(x**y) % z

d)

(x**y)*z