Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python programming quiz

Total questions: 26

Worksheet time: 11mins

Name
Class
Date
1.

Write the output of the following code:

x=2

x=5

x=x+x

print(x)

a)

7

b)

10

c)

4

d)

Error

2.

Write the output of the following code :

x=2

y=3

x+y+5

print(x+y)

a)

8

b)

6

c)

10

d)

5

3.

What is a keyword?

a)

Reserved Word

b)

Predefined Word

c)

Keywords are part of the syntax and they cannot be used as an identifier.

d)

All of them

4.

Which statement will display square of number (n)

a)

print(n * n)

b)

print(math.pow(n,2)) # math module is already imported

c)

All of the above

d)

Only First

5.

Which of the following data types is not supported in python?

a)

String

b)

Number

c)

List

d)

Slice

6.

Select the reserved keyword in python-

a)

else

b)

raise

c)

import

d)

All of them

7.

What will be the output of this string operation s[2:5] , if s="hello world" -

a)

lo

b)

llo

c)

llow

d)

ell

8.

What will be the output of this string operation s[6:] , if s="hello world" -

a)

'world'

b)

'orld'

c)

' world'

d)

'worl'

9.

What is the maximum possible length of the identifier?

a)

31 Characters

b)

36 Characters

c)

33 Characters

d)

34 Characters

10.

Which statement is adding remainder of 8 divided by 3 to the product of 5 and 6?

a)

8 % 3 + 5 * 6

b)

8/3 + 5 * 6

c)

8 // 3 + 6.5

d)

None of the above

11.

Is a,b = 6 statement will return an error.(T/F)

a)

True

b)

False

12.

Both the print statement will return same output (T/F)

a=9

b=a

print(id(a)) print(id(b))

a)

False

b)

True

13.

Write the output of the following code :

>>> a=9

>>> x=str(a)

>>> b=5

>>> y=str(b)

>>> x+y

a)

14

b)

9,5

c)

95

d)

None of the above

14.

In which language is Python written?

a)

English

b)

PHP

c)

C

d)

All of the above

15.

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

a)

.py

b)

.python

c)

.p

d)

None of these

16.

What do we use to define a block of code in Python language?

a)

Key

b)

Brackets

c)

Indentation

d)

None of these

17.

Which of the following declarations is incorrect?

a)

_x = 2

b)

__x = 3

c)

__xyz__ = 5

d)

None of these

18.

Write the output of the following code :

>>> 7+2//1**2 > 5+2**2//3

a)

True

b)

False

19.

Write the output of the following :

>>> num1 = 7

>>> num2 = 3

>>> num1 //= num2

>>> num1

a)

3

b)

2

c)

7

d)

1

20.

print(“I” + “am” + “in” + “school”) display________

a)

I am in school

b)

Iaminschool

c)

I Am In School

d)

iaminschool

21.

int(20.5 + 2.7) and int(20.5) + int(2.7) will produce the same result.(T/F)

a)

True

b)

False

22.

Study the following statements:

>>> str1 = "javat"  

>>> str2 = ":"  

>>> str3 = "point"  

>>> str1[-1:]  What will be the output of this statement?

a)

t

b)

j

c)

point

d)

java

23.

if s = "hello" then what will be the output of print(3*s)?

a)

hellohello

b)

3hello

c)

3*hello

d)

hellohellohello

24.

a = 5  

print("The type of a", type(a))  ?

a)

float

b)

int

c)

bool

d)

5

25.

str1 = 'hello javatpoint' #string str1

 str2 = ' how are you' #string str2 

then print (str1 + str2)?

a)

helo javapointhow are you

b)

helo javapoint how are you

c)

helojavapointhow are you

d)

helojavapoint howareyou

26.

Write the output of the following:

print(range(0,8,2))

a)

range(0, 8, 2)

b)

0,2,4,6

c)

Error

d)

None of the above