wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Worksheet

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following is NOT a feature of Python?

a)

Dynamically typed

b)

Interpreted language

c)

Requires explicit variable declaration with type

d)

Supports multiple programming paradigms

2.

Python is developed by:

a)

James Gosling

b)

Guido van Rossum

c)

Dennis Ritchie

d)

Bjarne Stroustrup

3.

What is the output of print(type(5.0))?

a)

b)

c)

d)

4.

Which of these is an immutable data type in Python?

a)

List

b)

Dictionary

c)

Tuple

d)

Set

5.

What will be the output of bool(0)?

a)

True

b)

False

c)

Error

d)

None

6.

What is the output of 10 // 3 in Python?

a)

3.33

b)

3

c)

4

d)

Error

7.

Which operator has the highest precedence in Python?

a)

** (Exponentiation)

b)

* (Multiplication)

c)

+ (Addition)

d)

and

8.

What does the += operator do?

a)

Addition assignment

b)

Concatenation

c)

Both a and b

d)

None of the above

9.

What will be printed? Python x = 10 if x > 15: print("Hi") elif x > 5: print("Hello") else: print("Bye")

a)

Hi

b)

Hello

c)

Bye

d)

None

10.

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

a)

continue

b)

break

c)

pass

d)

skip

11.

How many times will the following loop run? for i in range(5): print(i)

a)

4

b)

5

c)

6

d)

Infinite

12.

What is the output of this code? i = 0 while i < 3: print(i, end=" ") i += 1 else: print("Done")

a)

0 1 2

b)

0 1 2 Done

c)

Done 0 1 2

d)

Infinite loop

13.

Which loop is guaranteed to execute at least once?

a)

for loop

b)

while loop

c)

do-while loop (does not exist in Python)

d)

None

14.

What is the output of len([1, 2, [3, 4], 5])?

a)

3

b)

4

c)

5

d)

Error

15.

Which method adds an element at the end of a list?

a)

insert()

b)

append()

c)

extend()

d)

add()

16.

What does list1.extend([4,5]) do?

a)

Adds [4,5] as a single element

b)

Adds 4 and 5 as separate elements

c)

Replaces the list

d)

Error

17.

How do you access the last element of a list named mylist?

a)

mylist[-1]

b)

mylist[last]

c)

mylist.end()

d)

mylist.pop()

18.

What is the output of [1,2,3] * 2?

a)

[2,4,6]

b)

[1,2,3,1,2,3]

c)

[1,2,6]

d)

Error

19.

Which of the following creates a shallow copy of a list?

a)

list2 = list1

b)

list2 = list1.copy()

c)

list2 = list1[:]

d)

Both b and c

20.

What does mylist.pop() return?

a)

Removes and returns the last element

b)

Removes the first element

c)

Returns None

d)

Error if list is empty