Class XII Python Programming Test
Time Allowed: 3 hours
Maximum Marks: 70
Section A (1 mark each)
Question 1: Which of the following is an immutable data type in Python?
a) List
b) Dictionary
c) String
d) None of the above
Question 2: How do you add an element at the end of a list in Python?
a) append()
b) extend()
c) add()
d) insert()
Question 3: What is the data type of (‘apple’,)?
a) Tuple
b) String
c) List
d) Set
Question 4: Which of the following can be used as a dictionary key?
a) List
b) Tuple
c) Dictionary
d) Set
Question 5: What is the output of the following code?
print("Hello {name}".format(name="World"))
a) Hello name
b) Hello {name}
c) Hello World
d) Error
Section B (2 marks each)
Question 6: Write a Python statement to remove the element ‘apple’ from a set `fruits = {‘apple’, ‘banana’, ‘cherry’}`.
Question 7: Write a Python program to swap the values of two variables `a` and `b` without using a third variable.
Question 8: What is the difference between the `append()` and `extend()` methods of a list in Python?
Question 9: Write a program to iterate over a list using a for loop and print each element.
Question 10: Explain how to access elements from a dictionary in Python.
Section C (3 marks each)
Question 11: Write a program to count the number of vowels in a string entered by the user.
Question 12: Write a Python program to find the factorial of a number using a recursive function.
Question 13: Explain the concept of slicing in Python with examples.
Question 14: Write a program in Python to find the sum of the series 1+1/2+1/3+…+1/n using a loop.
Question 15: Explain the difference between a shallow copy and a deep copy of a list in Python with examples.
Section D (5 marks each)
Question 16: Write a Python program that takes a list of numbers from the user, and then prints the sum of all even numbers in the list.
Question 17: Write a Python program that asks the user for a string and prints the number of uppercase and lowercase letters in the string.
Question 18: Write a Python program to create a dictionary that contains the roll numbers (between 1 to 10) as keys and the corresponding student names as values.
Question 19: Write a program in Python to read a string and print the character which appears the maximum number of times along with the count.
Question 20: Write a Python program to implement a simple calculator that can add, subtract, multiply and divide, taking two numbers and the operator as input from the user.
Section E (10 marks)
Question 21: Write a Python program to simulate a library management system which will implement the following operations: 1. Add a book, 2. Issue a book, 3. Return a book, 4. View all books.