wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz#1_24March2020

Total questions: 30

Worksheet time: 19mins

Name
Class
Date
1.

Who is the father of Python Programming Language?

a)

Dennis Ritchie

b)

James Arthur Gosling

c)

Guido van Rossum

d)

Bjarne Stroustrup

2.

What is the output of the following code :

print( 9 // 2)

a)

4.5

b)

4.0

c)

4

d)

Error

3.

What is the output of the following program :

a)

021324

b)

012345

c)

Error

d)

102435

4.

What is the output of the following code?

for value in range (1,5):

print(value)

a)

Error

b)

12345

c)

1234

d)

2345

5.

What will be the output of the following?

a)

HelloHi

b)

Hello

c)

Hi

d)

Error

6.

What should come in the blank if we want to print HI! 6 times? for i in range(_____): print(“HI!”)

a)

1,5

b)

1,6

c)

5

d)

1,7

7.

If you want to check if the age is equal to or greater than 18, what should come in the blank: if age___18: print(“You can vote.”)

a)

<

b)

>!

c)

<=

d)

>=

8.

What will be the output of the following code:

a)

None of the following

b)

Error

c)

Even

d)

Odd

9.

if statement along with an else statement in Python is called ______ statement.

a)

elseif

b)

ifelse

c)

elif

d)

elsif

10.

What will be the output of the following? (3 < 1) and (4/0 > 1)

a)

False

b)

True

c)

Run Time Error

d)

None of these

11.

In the following statement, which operation will be evaluated first according to the order of precedence of operators in Python? (3*20+5)-16/4

a)

(3*20+5)

b)

16/4

c)

20+5

d)

3*20

12.

Can a break statement be used to exit a while loop?

a)

True

b)

False

13.

What will be the output of the following program?

a)

3

b)

2

c)

3

2

d)

Error

14.

What does the following Python code do?

a)

Print all integers from 1 to n

b)

Print all integers from 1 to n-1

c)

Print all integers from 2 to n

d)

Print all integers from 2 to n+1

15.

What will the output of the following Python program ?

a)

13

b)

10

c)

6

d)

9

16.

The following code should print all positive even numbers less than or equal to N. N is taken as input from the user. What should replace the ???? for the code to work correctly?

a)

i//2 == 0

b)

i%2 != 0

c)

i//2 != 0

d)

i%2 == 0

17.

The following code should print all positive odd numbers less than or equal to N. N is taken as input from the user. What should replace the ???? for the code to work correctly?

a)

i%2 == 1

b)

i = i + 2

c)

i = 1 + i * 2

d)

i = i * 2

18.

Which of the following symbols is used to make single line comments in Python?

a)

#

b)

@

c)

'''

d)

&

19.

Which of the following is not a valid identifier?

a)

A_

b)

_A

c)

1a

d)

_1

20.

What is the output of following statement?

sum = 10 + '10'

a)

1010

b)

20

c)

Error

d)

10'10'

21.

What will be the output of the following statement if the user has entered 20 as the input of x ?

x=input("Enter number")

print(10 + x)

a)

30

b)

1020

c)

Error

d)

20

22.

What will be the output of the following statement?

print( 15 + 20 / 5 + 3 * 2 - 1)

a)

19.0

b)

19

c)

12.0

d)

24.0

23.

What will be the output of the following program?

a = 7

b = 4

c = 2

print(a // b / c)

a)

0.85

b)

0

c)

0.5

d)

0.0

24.

Which of the following have the highest precedence in an expression?

a)

Addition

b)

Multiplication

c)

Exponent

d)

Parenthesis

25.

What will be the output, if the data 5 is shifted towards the left by 2 bits?

a)

20

b)

10

c)

1

d)

25

26.

What is the output of the following Python program ?

a)

3 5 7 9 11

b)

1 3 5 7 9

c)

The program will go into an infinite loop, printing 1 1 1 …

d)

The program will go into an infinite loop, printing nothing

27.

What is the output of following Code?

a)

4 3 Loop ended.

b)

5 4 3 Loop ended.

c)

4 3

d)

Loop ended.

28.

Find the output?

a)

4 3 1 0 Loop ended.

b)

4 3 2 1 0 Loop ended.

c)

4 3 Loop ended.

d)

4 3 1 Loop ended.

29.

Which of the following is false statement in python?

a)

int(10)==10

b)

int(10.0)==10

c)

int('10')==10

d)

None of these

30.

What will be the output of the following code?

a)

abcd

b)

0 1 2 3

c)

1 2 3 4

d)

a b c d