wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python

Total questions: 30

Worksheet time: 20mins

Name
Class
Date
1.

Which operator is used in Python to import modules from packages?

a)

.

b)

"->"

c)

&

d)

*

2.

Which translates source code into object code?

a)

compiler

b)

assembler

c)

interpreter

d)

all

3.

print(9//3,9/3)

a)

3 3.3

b)

3.3 3

c)

3.0 3.3

d)

3.3 3.3

4.

Valid operation?

a)

'2'-'1'

b)

'third'*'2'

c)

'sum'**3

d)

"2"+"1"

5.

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

a)

3

b)

21

c)

9

d)

33

6.

print(1.1+2.2==3.3)

a)

True

b)

False

c)

Error

d)

3.3

7.

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

8.

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

a)

hello123

b)

hello

c)

Error

d)

hello6

9.

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

10.

What is the output for − 'python ' [-3]?

a)

o

b)

t

c)

h

d)

negative index error

11.

What is the slice expression that gives every third character of string s, starting with the last character and proceeding backward to the first?

(a)  

12.

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

13.

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

14.

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

15.

y = 10

x = y += 2

print(x)

a)

12

b)

10

c)

0

d)

Error

16.

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

17.

Single line comment Symbol?

a)

//

b)

/

c)

$

d)

#

18.

Choose the correct function to get the character from ASCII number

a)

 ascii(number)

 

b)

 char(number)

 

c)

chr(number)

d)

ord(number)

19.

str1 = 'Welcome'

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

a)

Welcome PYnative

 

b)

WelcomPYnative

 

c)

Welcom PYnative

 

d)

WelcomePYnative

20.

str1 = "PYnative"

print(str1[1:4], str1[:5], str1[4:], str1[0:-1], str1[:-1])

a)

Yna PYnat tive PYnativ PYnativ

b)

PYn PYnat ive PYnativ vitanYP

c)

PYna PYnat ive PYnativ vitanYP

d)

Yna PYnat ive PYnativ vitanYP

21.

type('Hello, World!') output of the given code.

a)

<type 'int'>

b)

<type 'float'>

c)

<type 'str'>

d)

<type 'chr'>

22.

What is an Algorithm?

a)

A flowchart

b)

A decision

c)

A Pseudocode

d)

Step by step instructions used to solve a problem

23.

In a flowchart a calculation (process) is represented by 

a)

A rectangle   

b)

A parallelogram

c)

A rhombus 

d)

A circle

24.

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

25.

print("welcome0",end=" ")

print("welcome0")

a)

welcome#welcome0

b)

welcome#

welcome0

c)

welcome welcome0

d)

Invalid

26.

Which method should I use to convert String "welcome to the beautiful world of python" to "Welcome To The Beautiful World Of Python"

a)

capitalize()

b)

title()

c)

swapcase()

d)

eachcap()

27.

str = "my name is James bond"; print (str.capitalize())

a)

My Name Is James Bond

b)

 TypeError: unsupported operand type(s) for * or pow(): 'str' and 'int'

c)

 My name is james bond

d)

not a function

28.

python built in functions

a)

pow()

b)

Len()

c)

len()

d)

length()

29.

python keywords

a)

str()

b)

if

c)

else

d)

For

30.

decimal equivalent for (110001)2

a)

49

b)

48

c)

32

d)

16