wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics quiz

Total questions: 25

Worksheet time: 11mins

Name
Class
Date
1.

What is the type of 5/2 in Python?

a)

int

b)

float

c)

str

d)

bool

2.

which of these is mutable?

a)

tuple

b)

string

c)

list

d)

int

3.

what is the value of bool("")?

a)

True

b)

False

c)

None

d)

0

4.

What is the output?

a)

3

b)

3.33

c)

4

d)

0

5.

Which is correct syntax for taking integer input?

a)

x=int(input())

b)

x=input(int())

c)

x=input()

d)

x=int()

6.

What is the output?

a)

True

b)

False

c)

None

d)

Error

7.

Which operator has the highest precedence?

a)

+

b)

*

c)

**

d)

//

8.

What does 5%2 return?

a)

1

b)

2

c)

0

d)

2.5

9.

Which comparison is True?

a)

5=="5"

b)

5 is 5

c)

5!=5

d)

5>"5"

10.

What is the output?

a)

True

b)

False

c)

0

d)

Error

11.

What is the output?

a)

A

b)

S

c)

Error

d)

Nothing

12.

When using if statements in Python, which of the following is true?

a)

You can have multiple else blocks

b)

elif can appear before if

c)

Only one else block is allowed

d)

if statements cannot be nested

13.

What is the output?

a)

Yes

b)

No

c)

0

d)

Error

14.

Which is the output?

a)

True

b)

False

c)

1

d)

Error

15.

Which keyword is mandatory after "if" for alternatives?

a)

elif

b)

else

c)

then

d)

next

16.

What is the output?

a)

0,1,2,

b)

1,2,3

c)

0 1 2

d)

Error

17.

What is the output?

a)

0,1,2

b)

0 0 0

c)

infinite loop

d)

Error

18.

What does range(1,6,2) generate?

a)

[1,2,3,4,5]

b)

[1,3,5]

c)

[2,4,6]

d)

[0,1,2,3,4,5]

19.

What is the output?

a)

0 1 2

b)

0 1 2 3

c)

1 2 3

d)

Error

20.

What is the output?

a)

nohtyP

b)

Python

c)

Error

d)

n

21.

Which loop is best when the number of iterations is unknown?

a)

for

b)

while

c)

do-while

d)

infinte

22.

What is the output?

a)

[1,2,3,4]

b)

[1,2,3]

c)

7

d)

Error

23.

What is the output?

a)

64

b)

512

c)

256

d)

16

24.

Output of: len("Python")

a)

5

b)

6

c)

7

d)

Error

25.

Which of the following statements about python lists is correct?

a)

Lists are immutable

b)

Lists can contain mixed data types

c)

Lists must have unique elements

d)

Lists cannot contain another list