Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Semester Final 2025

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What is the output of the following code? python mylist = [1, 2, 3] print(mylist[1])

a)

1

b)

2

c)

3

d)

Error

2.

Which method is used to add an item at the end of a list?

a)

insert()

b)

add()

c)

append()

d)

extend()

3.

What does mylist[-1] return?

a)

First item

b)

Last item

c)

Second item

d)

Error

4.

Which method removes all items from a list?

a)

clear()

b)

delete()

c)

remove()

d)

pop()

5.

What is the output of: python x = [2, 4, 6] x.append([8, 10]) print(x)

a)

[2, 4, 6, 8, 10]

b)

[2, 4, 6, [8, 10]]

c)

[2, 4, 6, 8]

d)

Error

6.

What is the main difference between a list and a tuple?

a)

Tuples are faster

b)

Tuples are immutable

c)

Lists are immutable

7.

How do you define a tuple with one element?

a)

(4)

b)

[4]

c)

(4,)

d)

tuple(4)

8.

Which of these methods can be used on a tuple?

a)

append()

b)

remove()

c)

count()

d)

pop()

9.

What is the output of len((10, 20, 30))?

a)

2

b)

3

c)

1

d)

Error

10.

Can you change the value of an element in a tuple?

a)

Yes

b)

Only if it’s a number

c)

No

d)

Only using update()

11.

Which of these defines a dictionary correctly?

a)

{1, 2, 3}

b)

["a": 1, "b": 2]

c)

{"a": 1, "b": 2}

d)

(1, 2)

12.

What is the output of: python copy d = {"a": 1, "b": 2} print(d.get("c"))

a)

None

b)

0

c)

Error

d)

'c'

13.

Which method removes all elements from a dictionary?

a)

delete()

b)

clear()

c)

remove()

d)

pop()

14.

What is a key property of a set?

a)

Ordered

b)

Mutable and duplicates allowed

c)

No duplicates

d)

Immutable

15.

What is the output of: python copy s = {1, 2, 2, 3} print(s)

a)

{1, 2, 2, 3}

b)

{1, 2, 3}

c)

Error

d)

None

16.

Which method is used to add a single item to a set?

a)

append()

b)

add()

c)

insert()

d)

update()

17.

What will set1 & set2 return?

a)

Union

b)

Intersection

c)

Difference

d)

Symmetric difference

18.

Which data structure does not allow duplicates?

a)

List

b)

Tuple

c)

Dictionary

d)

Set

19.

Which of the following is not a valid dictionary method?

a)

pop()

b)

update()

c)

add()

d)

get()

20.

Which statement creates an empty dictionary?

a)

dict = ()

b)

dict = []

c)

dict = {}

d)

dict = set()

21.

Which operation is used to combine two lists?

a)

list1.add(list2)

b)

list1 + list2

c)

list1.join(list2)

d)

list1.append(list2)

22.

What is the output of sorted([3, 1, 2])?

a)

[1, 2, 3]

b)

[3, 2, 1]

c)

[1, 3, 2]

d)

None

23.

Which data structure allows both key-value pairs and is mutable?

a)

List

b)

Tuple

c)

Set

d)

Dictionary

24.

What is the output of: python t = (1, 2, 3) print(t[1])

a)

1

b)

2

c)

3

d)

Error

25.

What is the data type of 3.14?

a)

int

b)

float

c)

str

d)

double

26.

What is the output of: python x = 5 if x < 10: print("Small") else: print("Big")

a)

Small

b)

Big

c)

Error

d)

Nothing

27.

Which of the following is the correct syntax for an if statement?

a)

if x < 10 then:

b)

if(x < 10)

c)

if x < 10:

d)

if x < 10 {

28.

What does the following code print? python x = 3 if x > 5: print("High") elif x > 2: print("Medium") else: print("Low")

a)

High

b)

Medium

c)

Low

d)

Error

29.

What is the output of: python i = 1 while i < 4: print(i) i += 1

a)

a) 1 2 3

b)

b) 1 2 3 4

c)

c) 0 1 2

d)

d) 2 3 4

30.

What is the purpose of the break statement in a loop?

a)

Ends the program

b)

Skips the next iteration

c)

Exits the loop

d)

Restarts the loop

31.

What is the output of: python for i in range(5): if i == 3: continue print(i)

a)

0 1 2 3 4

b)

0 1 2 4

c)

0 1 2

d)

0 1 2 3

32.

What is the keyword to define a function?

a)

function

b)

func

c)

def

d)

define

33.

What does the following code print? python def greet(): return "Hello" print(greet())

a)

greet

b)

Hello

c)

None

d)

Error

34.

Which of the following is not a valid function call?

a)

sum([1, 2, 3])

b)

print("Hi")

c)

max(5, 9)

d)

def(3)

35.

What will the following function return? def add(x, y): return x + y print(add(2, 3))

a)

23

b)

5

c)

x + y

d)

Error

36.

What does the input() function return?

a)

Integer

b)

Float

c)

String

d)

Boolean

37.

What is the result of: python Copy name = input("Enter name: ") print("Hello", name)

a)

Hello

b)

name

c)

Hello name

d)

Hello followed by user input

38.

What is the output of: python Copy s = "hello" print(s.upper())

a)

HELLO

b)

hello

39.

Which of the following gets the last character of the string s = "python"?

a)

s[0]

b)

s[5]

c)

s[-1]

d)

s[len(s)]

40.

What will this return? python s = "data" print(len(s))

a)

3

b)

4

c)

5

d)

Error