Puterscience Class-XII CPBE-2023
Puterscience Class-XII CPBE-2023
SECTION A
1. State True or False: 1
“All keywords in Python are in lowercase.”
Page 1 of 12
5. Select the correct output of the code: 1
>>> s="i love my country"
>>> r = "i love my class"
>>> s[2:6] + r[-7:]
a) 'loveyclass'
b) 'lovey class'
c) 'loveclass'
d) 'love class'
6. Which function is used to write data in binary mode? 1
a) write
b) writelines
c) pickle
d) dump
7. Fill in the blank: 1
Duplication of a record is called ___________.
a) Redundancy
b) Inconsistency
c) Discrepancy
d) Integrity
8. The query to add a column ‘DOB’ of data type ‘DATE in table STUDENT. 1
a) ALTER STUDENT TABLE ADD DOB DATE;
b) ALTER TABLE STUDENT MODIFY DOB DATE;
c) ALTER TABLE STUDENT ADD DOB DATE;
d) ALTER STUDENT TABLE MODIFY DOB DATE;
Page 2 of 12
11. Write the output of the following code: 1
f= open("data.txt", "w")
L=["My\n", "name\n", "is\n", "Amit"]
f.writelines(L)
f.close( )
f= open("data.txt","r")
print(len (f.readline()))
a) 2
b) 4
c) 3
d) 5
12. Fill in the blank: 1
The command used to change the data in a SQL table is ___________.
a. UPDATE
b. MODIFY
c. ALTER
d. CHANGE
13. Fill in the blank: 1
In __________topology failure in the central networking device may lead to the failure of
complete network.
a) Bus
b) Star
c) Ring
d) Tree
14. Evaluate the following expression and identify the correct answer. 1
not True and not False or not True
a. False
b. NONE
c. NULL
d. True
Page 3 of 12
Q17 and 18 are ASSERTION AND REASONING 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
17. Assertion (A): Function can take input values as parameters, execute them and return the 1
output (if required) to the calling function with a return statement.
Reason (R): A function in Python can return multiple values.
18. Assertion (A): Pickle in Python is primarily used in serializing and deserializing a Python object 1
structure.
Reason (R): pickle.dump() method is used to read the object in file and pickle.load() method is
used to write the object from pickled file.
SECTION B
19. Raju has written a function to check the largest of two numbers. There are errors in his code. 2
Rewrite the correct code and underline the corrections made.
def larg()
a = int(Input("Enter any number"))
b = int(input("Enter any number"))
if a=>b:
print("First number is greater')
else:
print("Second number is greater")
20. Write any two advantages and disadvantages of Twisted Pair Cables. 2
OR
Write any two advantages and disadvantages of Bus Topology.
b. Define VoIP.
Page 4 of 12
24. Predict the output of the Python code given below: 2
def changer(str, s):
nwstr=' '
for x in str:
if x.isdigit():
nwstr=nwstr + s
elif x.isalpha():
if x.isupper():
nwstr=nwstr+x.lower()
else:
nwstr=nwstr+x.upper()
else:
nwstr=nwstr + '*'
return(nwstr)
print(changer('Exam 2023' , '#' ) )
OR
OR
SECTION C
26. a. Consider the following tables – SALESPERSON and ITEM: 1+2
Page 5 of 12
What will be the output of the following statement?
SELECT * FROM SALESPERSON NATURAL JOIN ITEM;
b. Write the output of the queries (i) to (iv) based on the table PAY given below:
Table: PAY
No Name Salary Area Age Grade Dept
1 Krippe 40000 West 45 C Civil
2 Ravina 35000 South 38 A Elec
3 Karan 60000 North 52 B Comp
4 Tarun 142000 East 29 A Civil
5 Aryan 50000 West 30 A Elec
27. Write a method Countvowels( ) in Python to read the Text File ‘Attitude.Txt’ and display the 3
number of uppercase vowels in the file.
Example: If the file content is as follows:
All Birds Find Shelter During A Rain.
But An Eagle Avoids Rain By Flying Above The Clouds.
Problems Are Common, But Attitude Makes The Difference.
Write a function Countchars( ) in Python, which should read each character of a Text File
“Character.Txt” and display the count of words starting with letter ' I ' (including both the
cases).
Example: If the file content is as follows:
Intelligence plus character - that is the goal of true education
Develop your character so that you are a person of integrity.
The Countchars( ) function should display the output as:
No. of Words Starting with letter I: 3
28. a. Write the outputs of the SQL queries (i) to (iv) based on the relations DEPT and WORKER 3
given below:
Page 6 of 12
i. SELECT GENDER, COUNT(GENDER) AS 'GENDER COUNT' FROM WORKER GROUP BY GENDER;
ii. SELECT DISTINCT CITY FROM DEPT;
iii. SELECT NAME, DOB FROM WORKER W, DEPT D WHERE W.DCODE=D.DCODE AND
GENDER='FEMALE';
iv. SELECT MIN(DOJ), MAX(DOB) FROM WORKER;
29. Write a function ZeroEnding(SCORE) that returns the sum of all the values in the List of SCORES 3
which are ending with the number zero(0).
For example:
If the SCORE contain [200, 456, 300, 100, 234, 678]
The sum should be displayed as 600
30. John has created a Dictionary containing name and price as key value pairs, of 5 items in an 3
Instrument Box.
Write a program, using User Defined Functions to perform the following operations:
Push the keys (name of the item) of the Dictionary into a Stack, where the corresponding
value (price) is less than 45.
Pop and display the content of the Stack.
For example:
If the sample content of the dictionary is as follows:
Items = { " Compass " : 65, " Divider ":60, " Protractor ":45, " Set Squares ":40,
" Eraser ":30, " Ruler ":32}
The output from the program should be:
Ruler
Eraser
Set Squares
Empty Stack
OR
Page 7 of 12
Hanna has a List containing 5 CITIES. You need to help her to create a program with separate
User Defined Functions to perform the following operations based on the List.
Traverse the content of the List and push the CITIES, which are starting with alphabet A
into a Stack.
Pop and display the content of the Stack.
For Example:
If the List CITIES contains:
["AHMEDABAD", "CHENNAI", "NEWDELHI", "AMRITSAR", "AGRA"]
The following should get displayed:
AGRA
AMRITSAR
AHMEDABAD
Stack Empty
SECTION D
31. Adams Corporation has head office in Mumbai is planning to set up its new centre at Noida,
Uttar Pradesh for its office and web-based activities. It has 4 blocks of buildings.
i. Suggest and draw the cable layout(s) to efficiently connect various blocks of buildings 1
within the Noida centre for connecting the digital devices.
Page 8 of 12
ii. Suggest the placement of the following device with justification. 1
(a) Repeater
(b) Hub/Switch
iii. Which kind of network (PAN/LAN/WAN) will be formed if the Noida office is connected 1
to its head office in Mumbai?
iv. Which of the following will you suggest to establish the online face-to-face 1
communication between the people in the head office at Mumbai with the people at
Noida?
a. Cable TV
b. Video Conferencing
c. E-mail
d. Text Chat
v. Which fast and very effective wireless transmission medium should preferably be used 1
to connect the head office at Mumbai with the centre at Noida?
b. The School is managing student data in ‘Student’ table in ‘School’ database. The code given
below connects to database School and retrieves all records and display total number of
students. The structure of a record of the table Student is:
RollNo – integer; Name – string; Class – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is ‘root’, Password is ‘abc’.
• The table exists in a MYSQL database named ‘School’.
Write the following missing statements to complete the code:
Page 9 of 12
Statement 1 – To create the cursor object.
Statement 2 – To fetches all the rows in the result set.
Statement 3 – To close the connection.
OR
a. Predict the output of the code given below:
s="Rs.12"
n, m = len(s), " "
for i in range(0, n):
if s[i].islower():
m = m +s[i]
elif s[i].isupper():
m = m +s[i+1]
elif s[i].isdigit():
m = m*int(s[i])
else:
m = '@'+m
print(m)
b. The code given below reads records from the table named Vehicle and displays only those
records which have model 2010. The structure of a record of table Vehicle is:
V_ID – integer; Name – string; Model – integer; Price – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is ‘root’
• Password is ‘abc’
• The table exists in a MYSQL database named ‘Transport’.
Write the following missing statements to complete the code:
Statement 1 – To make a connection to the database
Statement 2 – The query that extracts records of those vehicles whose model is 2010.
Statement 3 – To fetch single record from the results set
33. What is the significance of newline argument in open( ) function of CSV file? 5
Write a program in Python that defines and calls the following User Defined Functions:
Page 10 of 12
i. ADD( ) – To accept and add data of a Employee to a CSV file ‘Emp.csv’. Each record
consists of a list with field elements as Empid, Empname and Salary to store Employee
id, Employee name and Employee salary respectively.
ii. DISPLAY( ) – To display all the records present in the CSV file named ‘Emp.csv’.
OR
What is the function of csv.reader object?
Write a Program in Python that defines and calls the following User Defined Functions:
i. ADD( ) – To accept and add data of furniture to a CSV file ‘furdata.csv’. Each record
consists of a list with field elements as fid, fname and fprice to store furniture id,
furniture name and furniture price respectively.
ii. SEARCH( ) – To display the records of the furniture whose price is more than 10000.
SECTION E
34. Rubina creates a table SUPPLIER with a set of records to maintain the product details. After 1+1+2
creation of the table, she has entered data of 5 product details in the table.
Table:SUPPLIER
SNo PName CName Qty Price City
S1 Bread Britannia 150 8.00 Delhi
S2 Cake Britannia 250 20.00 Mumbai
S3 Coffee Nescafe 170 45.00 Delhi
S4 Chocolate Amul 350 10.00 Mumbai
S5 Sauce Maggi 300 36.00 Jaipur
Page 11 of 12
35. Consider Students data Sid, Sname and Fee. George wrote Python function to create binary file
‘std.dat’ and store their records. He now has to read and display all the records in to the file
‘std.dat’.
As a Python expert, help him to complete the following code based on the requirement given
below.
___________ # STATEMENT 1
def add_record():
f = open('std.dat','ab')
Sid =int(input('Student code:'))
Sname = input('Student Name:')
Fee = int(input('Fees:'))
d = [Sid, Sname, Fee]
____________ # STATEMENT 2
f.close()
def search():
______________ # STATEMENT 3
while True:
try:
___________ # STATEMENT 4
print(d)
except EOFError:
break
f.close()
Page 12 of 12