Unit 1 Python Revision 1
Unit 1 Python Revision 1
REVISED
SYLLABUS
COMPUTER
SCIENCE
CHAPTER WISE
QUESTION BANK
2025-26 TERM-I
GRADE 12
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
1 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
d. Mumbai#Mumbai#chennai#Delhi#
2 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
print(Str2[len(Str2)-1:-3:-1])
a. [‗Digital‘,‘Economy‘]
b. [‗The‘,‘Digital‘,‘Economy‘]
c. [‗economy‘,‘digital‘]
d. [‗Economy‘,‘Digital‘]
14 Observe the given code carefully: 1 MARK
a=20
def change(a):
b=20
a=a+b
change(10)
print(a)
Select the correct output from the given options:
a. 10
b. 20
c. 30
d. Error
18 Find and write the output of the following python code: 2 MARKS
for Name in [‗peter‘, ‗paul‘ , ‗ken‘, ‗priya‘,‘shirley‘]
print(Name)
if Name[0]==‘K‘:
break
else:
print(‗Finished‘)
print(‗Completed‘)
4 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
for i in range (4,0,-1):
a=z[i]
b=z[i-1]
print(Diff(a,b), ‗#‘ ,end=‘ ‗)
22. Rao has written a code to input a number and check whether it is 3 MARKS
prime or not. His code is having errors. Rewrite the correct
code
def prime():
n=int(input(―enter the number to check‖)
for i in range (2,n//2):
if n%i=0:
print(―number is not prime\n‖)
break:
else:
print(―number is prime\n‖)
25. Predict the output for the given python code: 3 MARKS
x= ―apple, pear,peach,banana,grapes‖
y=x.split(―,‖)
for z in y:
if z>‘f‘:
print(z.upper())
else:
print(z)
5 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
Find the output for the code:
x=2
while x<9:
print(x,end=‖ ―)
x=x + 1
27. Meera has written a code to input a number and check whether it is prime 3 MARKS
or not. Her code is having errors. Rewrite the correct code and underline
the corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0
print("Number is not prime \n")
break
else:
print("Number is prime \n‘)
28. Predict the output of the following code : 3 MARKS
d={"IND":"DEL","SRI":"COL","CHI":"BEI"}
str1=""
for i in d:
str1=str1 + str(d[i]) +"@"
str2=str1[ : -1]
print (str2)
29. Predict the output of the following code : 3 MARKS
def Total(Num=10):
Sum=0
for C in range(1, Num+1):
if C%2!=0:
continue
Sum+=C
return Sum
print(Total(4),end="$")
6 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
print(Total(),sep="@")
30. Predict the output of the Python code given below: 3 MARKS
def Calc(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Calc(A,B),'#', end=' ')
*******
7 | Page
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
7 What is the purpose of the 'with' statement in file handling? 1
A. To create multiple files simultaneously
B. To automatically close the file after operations are complete
C. To compress the file contents
D. To encrypt file data
8 Which mode is used to append content to an existing file? 1
A. 'w+'
B. 'r+'
C. 'a'
D. 'x'
9 What method is used to write a string to a file? 1
A. write()
B. append()
C. insert()
D. put()
10 A binary file ―Book.dat‖ has structure [BookNo, Book_Name, Author, 3
Price].
1. Write a user defined function CreateFile() to input data for a
record and add to Book.dat .
2. Write a function CountRec(Author) in Python which accepts the
Author name as parameter and count and return number of books by
the given Author are stored in the binary file ―Book.dat
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
16 Write a function countrec(sport name) in Python which accepts the 4
name of sport as parameter and count and display the coach name of
a sport which is passed as argument from the binary file ―sport.dat‖.
Structure of record in a file is given below ——————– – [sport
name, coach name]
17 A binary file ―salary.DAT‖ has structure [employee id, employee name, 4
salary]. Write a function countrec() in Python that would read contents
of the file ―salary.DAT‖ and display the details of those employee
whose salary is above 20000.
18 Amit is a monitor of class XII-A and he stored the record of all the 4
students of his class in a file named ―class.dat‖. Structure of record is
[roll number, name, percentage]. His computer teacher has assigned
the following duty to Amit
Write a function remcount( ) to count the number of students who
need remedial class (student who scored less than 40 percent)
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
print(f.read(4))
Q30 is Assertion(A) and Reason(R) based questions. Mark the correct choice
as: (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
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
32 Surya is a manager working in a recruitment agency. He needs to 5
manage the records of various candidates. For this, he wants the
following information of each candidate to be stored: - Candidate_ID –
integer - Candidate_Name – string - Designation – string - Experience –
float You, as a programmer of the company, have been assigned to do
this job for Surya.
Write a function to input the data of a candidate and append it in a
binary file.
Write a function to update the data of candidates whose experience is
more than 10 years and change their designation to "Senior Manager".
Write a function to read the data from the binary file and display the data
of all those candidates who are not "Senior Manager
33 Write a Python function that displays all the lines containing the 4
word 'vote' from a text file "Elections. bet". For example, if
the file contains : 3
In an election many people vote to choose their representative.
The candidate getting the maximum share of votes stands elected.
Normally, one person has to vote once.
The process of voting may vary with time and region.
Then the output should be :
In an election many people vote to choose their representative.
Normally, one person has to vote once.
34 Write a Python function that displays all the words starting and 4
ending with a vowel from a text file "Report. bet". The consecutive
words should be separated by a space in the output. For example, if the
file contains :
Once there was a wise man in a village.
He was an awesome story-teller.
He was able to keep people anchored while listening to him.
Then the output should be :
Once a a awesome able
35 A csv file "P _record. csv" contains the records of patients in a hospital. 4
Each record of the file contains the following data :
• Name of a patient
• Disease
• Number of days patient is admitted
• Amount
For example, a sample record of the file may be :
["Gunjan","Jaundice",4,15000]
Write the following Python functions to perform the specified operations
on this file :
(i) Write a function read_ data() which reads all the data from the
file and displays the details of all the 'Cancer' patients.
(ii) Write a function count_rec () which counts and returns the
number of records in the file.
*******
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026
HOLY ANGEL CBSE SCHOOL
Reddiyar Street (west), Near PerumalKoil, RETTANAI-604306
Tindivanam – T.K, Villuppuram –Dist, TamilNadu-India.
Phone: 04145-237214
Email: [email protected]
17. Julie has created a dictionary containing names and marks as key 3
value pairs of 6 students. Write a program, with separate user
defined functions to perform the following operations:
● Push the keys (name of the student) of the dictionary into a stack,
where the corresponding value (marks) is greater than 75.
● Pop and display the content of the stack.
For example: If the sample content of the dictionary is as follows:
R= {"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
The output from the program should be: TOM ANU BOB OM
*******
HOLY ANGEL CBSE SCHOOL /GRADE XII/DEPARTMENT OF CS/PREPARED BY: Mr.vimalraj R/2025-2026