Class XII Python Programming Test (Paper 8)
Time Allowed: 3 hours
Maximum Marks: 70
Section A (1 mark each)
Question 1: What is the output of the following code?
print('12' + '34')
a) 46
b) 1234
c) 56
d) ’12’ ’34’
Question 2: Which of the following is not a Python data type?
a) list
b) tuple
c) array
d) dictionary
Question 3: Which Python keyword is used to define a function?
a) func
b) define
c) def
d) function
Question 4: What is the output of the following code?
print(bool(0))
a) 0
b) False
c) True
d) None
Question 5: What is the purpose of the `pass` statement in Python?
a) To pass a value to a function
b) To create an empty code block
c) To exit a loop
d) To throw an exception
Section B (2 marks each)
Question 6: Write a Python program to find the length of the string without using built-in functions.
Question 7: Write a Python program to create a dictionary from two lists, where one list contains keys and the other contains values.
Question 8: What is a lambda function in Python? Give an example.
Question 9: Write a Python program to find the maximum number in a list without using built-in functions.
Question 10: Explain the use of `break` statement in Python loops with an example.
Section C (3 marks each)
Question 11: Write a Python function that takes a string as an argument and returns the reversed string.
Question 12: Write a Python program to perform linear search on a list of numbers.
Question 13: Explain the concept of default arguments in Python functions with an example.
Question 14: Write a Python program to merge two dictionaries.
Question 15: Write a Python program to find the sum of all elements in a list using recursion.
Section D (5 marks each)
Question 16: Write a Python program to create a simple class named ‘Student’ with attributes ‘name’ and ‘marks’. Also, write methods to set data and display data.
Question 17: Write a Python program to implement a queue using collections.deque.
Question 18: Write a Python program to find the second largest number in a list.
Question 19: Write a Python program to implement a simple stack with push and pop operations.
Question 20: Write a Python program that reads a CSV file and prints the content as a list of dictionaries.
Section E (10 marks)
Question 21: Write a Python program that simulates a simple ATM machine. The machine should have accounts with PINs, balances, and should be able to handle deposits, withdrawals, and balance inquiries.