Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python : Conditional Statement, Loops and Data Structure

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the correct syntax of an if statement in Python?

a)

if condition:

b)

if(condition);

2.

Which keyword is used to provide an alternative block in Python?

a)

else

b)

elseif

3.

Which keyword is used for multiple conditions in Python?

a)

elseif

b)

elif

4.

What will be the output of the code?

a)

Greater

b)

Error

5.

In a nested if, an if statement is written:

a)

Outside only

b)

Inside another if

6.

Which loop is used to iterate over a sequence in Python?

a)

for

b)

while

7.

Which loop is used when the number of iterations is not known in advance?

a)

for

b)

while

8.

What will be the output?

a)

0 1 2

b)

1 2 3

9.

Which keyword is used to exit from a loop early?

a)

break

b)

exit

10.

Which keyword is used to skip the current iteration of a loop?

a)

continue

b)

skip

11.

Which operator is used for string concatenation in Python?

a)

+

b)

*

12.

What will "Python" * 2 output?

a)

PythonPython

b)

Error

13.

Which method is used to convert a string into lowercase?

a)

lower()

b)

toLowerCase()

14.

Which function is used to find the length of a string?

a)

length()

b)

len()

15.

Which data structure is mutable in Python?

a)

List

b)

Tuple

16.

Which data structure allows duplicate values?

a)

Set

b)

List

17.

Which symbol is used to define a dictionary in Python?

a)

{}

b)

[]

18.

How do you access the value of a dictionary key?

a)

dict.key

b)

dict["key"]

19.

Which data structure does not allow duplicate values?

a)

Set

b)

List

20.

Which data structure maintains insertion order?

a)

Dictionary

b)

Set