0% found this document useful (0 votes)
457 views9 pages

Exact Python Questions ClassXII

Uploaded by

cs1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
457 views9 pages

Exact Python Questions ClassXII

Uploaded by

cs1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

POINT CALIMERE INTERNATIONAL SCHOOL

(SENIOR SECONDARY)

(Affiliated to CBSE- vide Approval No: 1930551)

KURAVAPULAM, VEDARANYAM

REVISION– I EXAMINATION-2025

Subject: Computer Science (083) Maximum Marks:70

Grade: XII-A&B Date: 00/00/2025

General Instructions:

This question paper contains 37 questions.

All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions.

The paper is divided into 5 Sections- A, B, C, D and E.

Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.

Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.

Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.

Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.

Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.

All programming questions are to be answered using Python Language only.

In-case of MCQ, text of the correct answer should also be written.

Section A
1 State if the following statement is True or False:
Using the statistics module, the output of the below statements will be 20:
import statistics
statistics.median([10, 20, 10, 30, 10, 20, 30])

2 What will be the output of the following code?


L = ["India", "Incredible", "Bharat"]
print(L[1][0] + L[2][-1])

a) IT b) it c) It d) iT
3 Consider the given expression:
print(19<11 and 29>19 or not 75>30)
Which of the following will be the correct output of the given expression?
a) True b) False c) Null d) No output

4 What will be the output of the following Python code?


str= "Soft Skills"
print(str[-3::-3])

a) lSf b) Stkl c) StKi d) l

5 Write the output of the following Python code:


for k in range(7,40,6):
print ( k + '-' )

6 What will be the output of the following Python statement:


print(10-3**2**2+144/12)

7 What will be the output of the following Python code?

try:
x = 10 / 0
except Exception:
print("Some other error!")
except ZeroDivisionError:
print("Division by zero error!")

a) Division by zero error! b) Some other error! c) ZeroDivisionError d) Nothing is printed

8 What will be the output of the following Python code?

my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"}


print(my_dict.get("profession", "Not Specified"))

a) Alicia b) DELHI c) None d) Not Specified

9 What possible output is expected to be displayed on the screen at the time of execution of the
Python program from the following code?

import random
L=[10,30,50,70]
Lower=random.randint(2,2)
Upper=random.randint(2,3)
for K in range(Lower, Upper+1):
print(L[K], end="@")
a) 50@70@ b) 90@ c) 10@30@50@ d) 10@30@50@70@

10 What will be the output of the following Python code?


i=5
print(i,end='@@')
def add():
global i
i = i+7
print(i,end='##')
add()
print(i)

a) 5@@12##15 b) 5@@5##12 c) 5@@12##12 d) 12@@12##12

11 What is the output of the given Python code?


st='Waterskiing is thrilling!'
print(st.split("i"))

a) ['Watersk', 'ng ', 's thr', 'll', ‘ng!'] b) ['Watersk', '', 'ng ', 's thr', 'll', 'ng!'] c) ['Watersk', 'i', 'ng ',
's thr', 'll', ‘ng!'] d) Error

11. State if the following statement is True or False:


Using the statistics module, the output of the below statements will be 15:

import statistics
statistics.mode([10, 15, 15, 20, 25, 15, 30])

12. What will be the output of the following code?

L = ["Python", "Programming", "Language"]


print(L[0][2] + L[1][-1])

a) Pg b) Pm c) tn d) yn

13. Consider the given expression:

print(8>6 or 12<5 and not 20==20)

Which of the following will be the correct output of the given expression?
a) True b) False c) None d) Error
14. What will be the output of the following Python code?

text = "Programming"
print(text[::2])

a) Pormig b) rgamn c) Poramn d) Prgamn

15. Write the output of the following Python code:

for k in range(5,25,4):
print(k, end="#")

16. What will be the output of the following Python statement?

print(20 + 2**3*2 - 5)

17. What will be the output of the following Python code?

try:
x = int("abc")
except ValueError:
print("Invalid conversion!")
except Exception:
print("Some other error!")

a) Invalid conversion! b) Some other error! c) abc d) Nothing is printed

18. What will be the output of the following Python code?

student = {"roll": 101, "name": "Ravi", "marks": 85}


print(student.get("grade", "Not Assigned"))

a) 101 b) Ravi c) 85 d) Not Assigned

19. What possible output is expected to be displayed on the screen at the time of
execution of the Python program from the following code?

import random
nums = [5, 15, 25, 35]
low = random.randint(0,1)
up = random.randint(2,3)
for i in range(low, up+1):
print(nums[i], end="*")

a) 1525 b) 51525* c) 2535 d) 5152535

20. What will be the output of the following Python code?

x=3
print(x, end='!!')
def update():
global x
x = x*4
print(x, end='@@')
update()
print(x)

a) 3!!12@@12 b) 3!!3@@12 c) 3!!12@@3 d) 12!!12@@12

21 Assertion (A): The expression (1, 2, 3, 4).append(5) in Python will modify the original
sequence datatype.
Reason (R): The append() method adds an element to the end of a list and modifies the list in
place.

Choices:
a) Both A and R are True and R is the correct explanation for A.
b) Both A and R are True and R is not the correct explanation for A.
c) A is True but R is False.
d) A is False but R is True.

Section B
22 A. Explain the difference between explicit and implicit type conversion in Python with a
suitable example.

23 The code provided below is intended to remove the first and last characters of a given string
and return the resulting string. However, there are syntax and logical errors in the code. Rewrite it
after removing all the errors. Also, underline all the corrections made.

define remove_first_last(str):
if len(str) < 2:
return str
new_str = str[1:-2]
return new_str

result = remove_first_last("Hello")
Print("Resulting string: " result)

24 A. (Answer using Python built-in methods/functions only):


I. Write a statement to find the index of the first occurrence of the substring "good" in a string
named review.
II. Write a statement to sort the elements of list L1 in descending order.

OR

B. Predict the output of the following Python code:

text="Learn Python with fun and practice"


print(text.partition("with"))
print(text.count("a"))

25 A. Write a function remove_element() in Python that accepts a list L and a number n. If the
number n exists in the list, it should be removed. If it does not exist, print a message saying
"Element not found".

26 Predict the output of the Python code given below:

emp = {"Arv": (85000,90000),"Ria": (78000,88000),"Jay": (72000,80000),"Tia": (80000,70000)}


selected = [ ]
for name in emp:
salary = emp[name]
average = (salary[0] + salary[1]) / 2
if average > 80000:
selected.append(name)
print(selected)

27 Explain the difference between break and continue statements in Python with a suitable
example.

28 Write a Python function add_contact() that accepts a dictionary phone_book, a name, and a
phone number. The function should add the name and phone number to the dictionary. If the
name already exists, print "Contact already exists" instead of updating it.

Section C
29 A. Write a Python function that displays the number of times the word "Python" appears in a
text file named "Prog.txt".
30 A list containing records of products as
L = [("Laptop", 90000), ("Mobile", 30000), ("Pen", 50), ("Headphones", 1500)]

Write the following user-defined functions to perform operations on a stack named Product to:

I. Push_element() – To push an item containing the product name and price of products costing
more than 50 into the stack.
Output: [('Laptop', 90000), ('Mobile', 30000), ('Headphones', 1500)]

II. Pop_element() – To pop the items from the stack and display them. Also, display "Stack
Empty" when there are no elements in the stack.

Output:
('Headphones', 1500)
('Mobile', 30000)
('Laptop', 90000)
Stack Empty

31 A. Predict the output of the following Python code:


s1="SQP-25"
s2=""
i=0
while i<len(s1):
if s1[i]>='0' and s1[i]<='9':
Num=int(s1[i])
Num-=1
s2=s2+str(Num)
elif s1[i]>='A' and s1[i]<='Z':
s2=s2+s1[i+1]
else:
s2=s2+' '^
i+=1
print(s2)
Section D
32 Predict the output of the following Python code:
wildlife_sanctuary = ["Kaziranga", "Ranthambhore", "Jim Corbett", "Sundarbans", "Periyar",
"Gir", "Bandipur"]
output = [ ]
for sanctuary in wildlife_sanctuary:
if sanctuary[-1] in 'aeiou':
output.append(sanctuary[0].upper())
print(output)

33 Raj is the manager of a medical store. To keep track of sales records, he has created a CSV file
named Sales.csv, which stores the details of each sale.

The columns of the CSV file are: Product_ID, Product_Name, Quantity_Sold and
Price_Per_Unit.

Help him to efficiently maintain the data by creating the following user-defined functions:

I. Accept() – to accept a sales record from the user and add it to the file Sales.csv.

II. CalculateTotalSales() – to calculate and return the total sales based on the Quantity_Sold and
Price_Per_Unit.

34 Write and call a Python function to read lines from a text file STORIES.TXT and display
those lines which doesn’t start with a vowel (A, E, I, O, U) irrespective of their case.

35 Sneha is the librarian of a school. To maintain the records of issued books, she has created a
CSV file named Library.csv, which stores the details of each transaction.

The columns of the CSV file are: Book_ID, Book_Title, Student_Name, Days_Issued.

Help her to efficiently maintain the data by creating the following user-defined functions:

I. AddRecord() – to accept a library record from the user and add it to the file Library.csv.

II. CalculateFine() – to calculate and return the total fine collected, assuming the fine is ₹2 per
day for each issued book beyond 7 days.

Section E
36 Mr. Ravi, a manager at a tech company, needs to maintain records of employees. Each record
should include: Employee_ID, Employee_Name, Department and Salary.
Write the Python functions to:
I. Input employee data and append it to a binary file.
II. Update the salary of employees in the "IT" department to 200000.

37 Mrs. Ananya, principal of a school, needs to maintain records of students. Each record should
include: Admission_No, Student_Name, Class, and Percentage.

Write the Python functions to:

I. Input student data and append it to a binary file.


II. Update the percentage of students in Class "XII" to 100 if their current percentage is above 95.

You might also like