Class XII Python Programming Test (Paper 3)
Time Allowed: 3 hours
Maximum Marks: 70
Section A (1 mark each)
Question 1: What is the output of the following code?
print('ab' * 3)
a) ababab
b) ab3
c) abab
d) Error
Question 2: What is the result of `5 // 2` in Python?
a) 2
b) 2.5
c) 3
d) None of the above
Question 3: What is the default order of elements in a dictionary as of Python 3.7?
a) Ascending order
b) Descending order
c) Insertion order
d) Random order
Question 4: Which function is used to read the entire content of a file as a string in Python?
a) read()
b) readline()
c) readlines()
d) readfile()
Question 5: What will be the output of the following code?
print('Hello', end='@')
a) Hello
b) Hello@
c) Hello@end
d) Error
Section B (2 marks each)
Question 6: Write a Python program to find the square of each number in a given list using a list comprehension.
Question 7: Write a Python program that takes a tuple as input and converts it into a list.
Question 8: Explain the use of `continue` statement in Python loops with an example.
Question 9: Write a Python program to find the index of an element in a list. If the element is not in the list, print a message indicating that it is not found.
Question 10: Explain the concept of slicing in Python strings with an example.
Section C (3 marks each)
Question 11: Write a Python program to swap the values of two variables without using a third variable.
Question 12: Write a Python function that accepts a list of numbers and returns a list of the even numbers.
Question 13: Explain the use of the `enumerate()` function in Python with an example.
Question 14: Write a Python program that accepts a dictionary from the user and prints the keys and values in separate lists.
Question 15: Write a Python program to find the factorial of a number using recursion.
Section D (5 marks each)
Question 16: Write a Python program that reads a text file and prints the number of lines, words, and characters in the file.
Question 17: Write a Python program to implement a simple calculator that can add, subtract, multiply, and divide two numbers.
Question 18: Write a Python program to remove duplicates from a list and keep the order of the remaining elements.
Question 19: Write a Python program that reads a string and prints the number of uppercase letters, lowercase letters, digits, and whitespace characters.
Question 20: Write a Python program to count the frequency of each word in a given string.
Section E (10 marks)
Question 21: Write a Python program that simulates a simple library management system. The system should be able to add, view, update, and delete books (CRUD operations) and should also handle basic input validation.