Python Simulated Final Exam – Set 2:
Answer Key & Marking Scheme
Total Marks: 100
Part I: Multiple Choice Answers (2 marks each, Total: 40 marks)
1. B
2. C
3. B
4. C
5. B
6. C
7. A
8. A
9. C
10. D
11. A
12. C
13. C
14. C
15. B
16. B
17. B
18. A
19. C
20. A
Part II: Code Reading (4 marks each, Total: 12 marks)
1. [1, 3] — removes the element 2 from the list.
2. True — one condition is true so 'or' yields True.
3. 7 — function adds two integers and returns result.
Part III: Programming Tasks (11 marks each, Total: 33 marks)
1.
def min_max(lst):
return max(lst), min(lst)
2.
def count_vowels(text):
count = 0
for ch in [Link]():
if ch in 'aeiou':
count += 1
return count
3.
def input_sum():
total = 0
while True:
n = int(input("Enter a number: "))
if n < 0:
break
total += n
print("Total:", total)
Part IV: Comprehensive Task (15 marks)
Sample implementation:
books = {}
while True:
action = input("add/show/search/exit: ")
if action == "add":
title = input("Title: ")
author = input("Author: ")
books[title] = author
elif action == "show":
for t, a in [Link]():
print(f"{t} by {a}")
elif action == "search":
title = input("Enter title: ")
print([Link](title, "Book not found."))
elif action == "exit":
break