0% found this document useful (0 votes)
79 views

12 Computer Science Sp 01 A

Uploaded by

Anmol
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

12 Computer Science Sp 01 A

Uploaded by

Anmol
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

myCBSEguide

Class 12 - Computer Science


Sample Paper - 01 (2024-25)

Maximum Marks: 70
Time Allowed: : 3 hours

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 true or false:
In a nested loop, a break statement terminates all the nested loops in one go.
a) True
b) False
2. A relational database consists of a collection of:
a) Fields
b) Keys
c) Records
d) Tables
3. fetchall() method fetches all rows in a result set and returns a:
a) Tuple of strings
b) Tuple of lists
c) List of tuples
d) List of strings
4. What is the output of the below program?
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a = b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)
a) 3 is maximum

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


1 / 18
myCBSEguide
b) 4
c) 4 is maximum
d) 3
5. What is the output of the following?
d = {0, 1, 2}
for x in d.values() :
print (x)
6. Which type of transmission media is the least expensive to manufacture?
a) Twisted pair cable
b) CAT cable
c) Coaxial
d) Fibre optic
7. Which character is used to create a new file in csv?
a) x
b) r
c) r+
d) w
8. l1 = [1,2,3,4,5]
l1.append([5,6,[7,8,[9,10])
What will be the final length of l1?
a) 10
b) 5
c) 8
d) Error
9. The HAVING clause does which of the following?
a) Acts like a WHERE clause but is used for columns rather than groups.
b) Acts like a WHERE clause but is used for rows rather than columns.
c) Acts like a WHERE clause but is used for groups rather than rows.
d) Acts EXACTLY like a WHERE clause.
10. Write a line of code that writes "Hello world!" to a file opened with file object my file.
11. State true or false:
The default values for parameters are considered only if no value is provided for that parameter in the function call
statement.
a) True
b) False
12. When a stack, implemented as an array/list of fixed size, is full and no new element can be accommodated, it is called an
________.
a) OVERFLOW
b) NOFLOW
c) EXTRAFLOW
d) UNDERFLOW
13. In SQL, write the name of the aggregate function which will display the cardinality of a table.
14. A ________ is a network spread across states, countries or whole world.
a) PAN
b) LAN
c) WAN

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


2 / 18
myCBSEguide
d) MAN
15. What is the output of following code ?
def f():
x = (2856 / 156) % 89
print(x++)
x* = 34
f()
a) 19
b) 18
c) 646
d) Error
16. Which of the following is not a sequential datatype in Python?
a) List
b) Dictionary
c) Tuple
d) String
17. Which transmission media is capable of having a much higher bandwidth (data capacity)?
a) Untwisted cable
b) Twisted pair cable
c) Fibre optic
d) Coaxial
18. Which part of TCP/IP is responsible for dividing a file or message into very small parts, at the source computer?
a) ISP
b) Both TCP and IP
c) TCP
d) IP
19. Assertion (A): The tuple items cannot be deleted by using the del keyword.
Reason (R): To delete an entire tuple, we can use the del keyword with the tuple name.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
20. Assertion (A): pandas is defined as an open-source library that is built on top of the NumPy library.
Reason (R): pandas provides fast analysis, data cleaning, and preparation of the data for the user.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
21. Assertion (A): If you try to change the value of a frozenset item this will cause an error.
Reason (R): The frozenset() function returns an changeable frozenset object
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
To practice more questions & prepare well for exams, download myCBSEguide.com App. It provides complete

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


3 / 18
myCBSEguide
study material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8.com App to
create similar papers with their own name and logo.
Section B
22. Write Python code to create a table location with the following fields
id id of the location
bidycode code of the building

room type of rooms

capacity capacity of the room


23. Observe the given list and find the answer of questions that follows.
list1 = [23, 45, 63, ‘Hello’, 20 ‘World’, 15, 18]
i. list1 [-3]
ii. list[3]

OR

Draw a flow chart to find the factorial of any number.


24. The table Company of database connect contains the following records
Name Dept Salary
ABC DBA 35000

XYZ Analyst 42000

ABC1 DBA 40000

What will be the output of following code?

import mysql.connector
con = mysql.connector.connect(host = "localhost",
user = "system",passwd = "hello",database = "connect")
cur = con.cursor()
cur.execute("select Name, Salary from Company")
display = cur.fetchone()
print(display)

25. Predict the output.

a, b = 10, 15
x = 20
y = 25
a = x + y - b
x = a + b - y + 10
z = y + b * 3 + a
x = 50
a = x + y + z
print("a :", a)
print("b :", b)
print("x :", x)

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


4 / 18
myCBSEguide
print("y :", y)
print("z :", z)

OR

What is the length of the tuple shown below?


t = (((('a', 1), 'b', 'c'), 'd', 2), 'e', 3)
26. Consider a binary file Employee.dat containing details such as empno:ename:salary (separator ':'). Write a Python
function to display details of those employees who are earning between 20000 and 40000. (Both values inclusive)

OR

Write a function count_Dwords () in Python to count the words ending with a digit in a text file "Details.txt".
Example:
If the file content is as follows:
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4
27. Explain the use of a default parameter in a Python function with the help of a suitable example.
28. Explain the two types of duplex communication.
Section C
29. Write a method in Python to find and display the prime number between 2 to n. Pass n as an argument to the method.

OR

Write functions in Python for InsertQ(Names) and RemoveQ(Names) for performing insertion and removal operations
with a queue of list which contains names of students. The function must check for Empty Queue.
30. Write the output of SQL queries (a) to (d) based on the table VACCINATION_DATA given below:

TABLE: VACCINATION_DATA

VID Name Age Dose1 Dose2 City


101 Jenny 27 2021-12-25 2022-01-31 Delhi

102 Harjot 55 2021-07-14 2021-10-14 Mumbai

103 Srikanth 43 2021-04-18 2021-07-20 Delhi


104 Gazala 75 2021-07-31 NULL Kolkata

105 Shiksha 32 2022-01-01 NULL Mumbai


a. SELECT Name, Age FROM VACCINATION_DATA
WHERE DOSE2 IS NOT NULL AND Age >40;
b. SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
c. SELECT DISTINCT CIEY EROM VACCINATION_DATA;
d. SELECT MAX (Dose1), MIN (Dose2) FROM VACCINATION_DATA;

OR

What is the purpose of using MySQL?


31. What is the difference between a local variable and a global variable? Also, give a suitable Python code to illustrate both.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


5 / 18
myCBSEguide
OR

Write definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are not even.
Section D
32. Write a program to implement a stack for these book details (book no., book name). That is, now each item node of the
stack contains two types of information - a book no. and its name. Just implement Push and display operations.

OR

A line of text is read from the input terminal into a stack. Write a program to output the string in the reverse order, each
character appearing twice.
(ie.g., the string a b c d e should be changed to ee dd cc bb aa)
33. A binary file "PATIENTS.dat" has structure (PID, NAME, DISEASE).
Write the definition of a function countrec() in Python that would read contents of the file "PATIENTS.dat" and
display the details of those patients who have the DISEASE as 'COVID-19'. The function should also display the total
number of such patients whose DISEASE is 'COVID-19'.
34. Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i) to (v).

TABLE: DOCTOR

ID NAME DEPT SEX EXPERIENCE

101 John ENT M 12


104 Smith ORTHOPEDIC M 5

107 George CARDIOLOGY M 10


114 Lara SKIN F 3

109 K George MEDICINE F 9


105 Johnson ORTHOPEDIC M 10

117 Lucy ENT F 3


111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15

TABLE: SALARY

ID BASIC ALLOWANCE CONSULTATION


101 12000 1000 300
104 23000 2300 500

107 32000 4000 500


114 12000 5200 100
109 42000 1700 200

105 18900 1690 300


130 21700 2600 300
i. Display NAME of all doctors who are in MEDICINE department having more than 10 yrs experience from the table
DOCTOR.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


6 / 18
myCBSEguide
ii. Display the average salary of all doctors working in ENT department using the tables DOCTOR and
SALARY.SALARY = BASIC + ALLOWANCE.
iii. Display the minimum ALLOWANCE of female doctors.
iv. Display the highest consultation fee among all male doctors.
v. To display the detail of doctor who have experience more than 12 years.

OR

Consider the following tables PRODUCT and CLIENT. Write SQL commands for the following statements.

Table: PRODUCT

P_ID ProductName Manufacturer Price

TP01 Talcum Powder LAK 40


FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55

SH06 Shampoo XYZ 120


FW12 Face Wash XYZ 95

Table: CLIENT

C_ID ClientName City P_ID

01 Cosmetic Shop Delhi FW05


06 Total Health Mumbai BS01
12 Live Life Delhi SH06

15 Pretty Woman Delhi FW12


16 Dreams Banglore TP01
i. To display the details of those Clients whose City is Delhi.
ii. To display the details of Products whose Price is in the range of 50 to 100 (Both values included).
iii. To display the ClientName, City from table Client, and ProductName and Price from table Product, with their
corresponding matching P_ID.
iv. To increase the Price of all Products by 10.
35. Write a program that inputs the main string and then creates an encrypted string by embedding a short symbol-based
string after each character. The program should also be able to produce the decrypted string from an encrypted string.
Section E
36. The Freshminds University of India is starting its first campus in Ana Nagar of South India with its center admission
office in Kolkata. The university has 3 major blocks comprising of Office Block, Science Block and Commerce Block in
the 5 km area Campus.

As a network expert, you need to suggest the network plan as per (i) to (iv) to the authorities keeping in mind the

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


7 / 18
myCBSEguide
distance and other given parameters.
Expected Wire distances between various locations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m

Science Block to Commerce Block 15 m


Kolkata Admission office to Ana Nagar Campus 2450 km

Expected number of Computers to be installed at various locations in the University are as follows:
Office Block 10

Science Block 140


Commerce Block 30
Kolkata Admission office 8
i. What type of server should be installed in university?
Dedicated
Non-dedicated
ii. Suggest the most suitable place (i.e., block) to house the server of this university with a suitable reason.
iii. Suggest an efficient device from the following to be installed in each of the blocks to connect all the computers:
MODEM
SWITCH
GATEWAY
iv. Suggest the most suitable (very high speed) service to provide data connectivity between Admission Office located in
Kolkata and the campus located in Ana Nagar from the following options:
Telephone line
Fixed-Line Dial-up connection
Co-axial Cable Network
GSM
Leased line
Satellite Connection
37. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables:

TABLE: BOOK

Code BNAME TYPE

F101 The Priest Fiction


L102 German easy Literature
C101 Tarzan in the lost world Comic

F102 Untold story Fiction


C102 War heroes Comic

TABLE: MEMBER

MNO MNAME CODE ISSUEDATE

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


8 / 18
myCBSEguide
M101 RAGHAV SINHA LI 02 2016-10-13
M103 S ARTHAKJ OHN FI 02 2017-02-23

M102 ANISHA KHAN C101 2016-06-12


i. To display all details from table MEMBER in descending order of ISSUEDATE.
ii. To display the BNO and BNAME of all Fiction Type books from the table Book.
iii. To display the TYPE and number of books in each TYPE from the table BOOK.
iv. To display all MNAME and ISSUEDATE of those members from table MEMBER who have books issued (i.e.,
ISSUEDATE) in the year 2017.
v. SELECT MAX (ISSUEDATE) FROM MEMBER
vi. SELECT DISTINCT TYPE FROM BOOK
vii. SELECT A.CODE, BNAME, MNO. MNAME FROM BOOK A. MEMBER B WHERE A.CODE= B.CODE
viii. SELECT BNAME FROM BOOK WHERE TYPE NOT IN ("FICTION", "COMIC")

OR

Consider the following tables CABHUB and CUSTOMER and answer the following parts of this question :
Table: CABHUB

Vcode VehicleName Make Color Capacity Charges

100 Innova Toyota WHITE 7 15


102 SX4 Suzuki BLUE 4 14
104 C Class Mercedes RED 4 35

105 A-Star Suzuki WHITE 3 14


108 Indigo Tata SILVER 3 12

Table: CUSTOMER

CCode CName Vcode

1 Hemant Sahu 101


2 Raj Lai 108
3 Feroza Shah 105

4 Ketan Dhal 104


Give the output of the following SQL queries :
i. SELECT COUNT (DISTINCT Make) FROM CABHUB ;
ii. SELECT MAX(Charges), MIN(Charges) FROM CABHUB ;
iii. SELECT COUNT(*), Make FROM CABHUB ;
iv. SELECT VehicleName FROM CABHUB WHERE Capacity = 4;
To practice more questions & prepare well for exams, download myCBSEguide.com App. It provides complete
study material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8.com App to
create similar papers with their own name and logo.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


9 / 18
myCBSEguide

Class 12 - Computer Science


Sample Paper - 01 (2024-25)

Solution

Section A
1. (b) False
Explanation: False
2. (d) Tables
Explanation: A relational database consists of a collection of tables that store interrelated data.
3. (c) List of tuples
Explanation: List of tuples
4. (c) 4 is maximum
Explanation: Here, we define a function called printMax that uses two parameters called a and b. We find out the
greater number using a simple if..else statement and then print the bigger number.
5. The above code will produce error as the statement above is not correct form of dictionary, which has keys and values.
6. (a) Twisted pair cable
Explanation: Twisted pair cable is the least expensive transmission media.
7. (a) x
Explanation: x
8. (b) 5
Explanation: A list is getting added in list l1 which will be counted as one item for the list.
9. (c) Acts like a WHERE clause but is used for groups rather than rows.
Explanation: Acts like a WHERE clause but is used for groups rather than rows.HAVING is used to filter values after
they have been groups.
10. myfile.write("Hello world!")
File object is myfile, and write() function writes string "Hello World!" into the file.
11. (a) True
Explanation: True
12. (a) OVERFLOW
Explanation: When a stack, implemented as an array/list of fixed size, is full and no new element can be
accommodated, it is called an OVERFLOW.
13. The aggregate function that can display the cardinality (number of rows) of a table in SQL is COUNT.
14. (c) WAN
Explanation: WAN spans a large geographical area, often a country or a continent and uses various commercial and
private communication lines to connect computers.
15. (d) Error
Explanation: ++ is not defined as an increment operator in python.
16. (b) Dictionary
Explanation: Dictionary
17. (c) Fibre optic
Explanation: The transmission capacity of optical fibre cable is 26,000 times higher than that of twisted pair cable.
18. (c) TCP
Explanation: TCP
19. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: The tuple items cannot be deleted individually by using the del keyword as tuple is immutable. To delete

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


10 / 18
myCBSEguide
an entire tuple, we can use the del keyword with the tuple name.
20. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: pandas is defined as an open-source library that is built on top of the NumPy library and it provides fast
analysis, data cleaning, and preparation of the data for the user.
21. (c) A is true but R is false.
Explanation: The frozenset() function returns an unchangeable/immutable version of a set object. The elements of set
can be changed at any time but the elements of frozenset remains same. If you try to change the value of a frozenset
item, it will cause an error.
To practice more questions & prepare well for exams, download myCBSEguide.com App. It provides complete study
material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8.com App to create
similar papers with their own name and logo.
Section B
22. import MySQLdb
db = MySQLdb.connect("localhost", "Admin", "Ad123", "HMD")
cursor= db.cursor()
cursor.execute("DROP TABLE IF EXISTS Location")
sql=" " "Create Table location (id Numeric(5) PRIMARY KEY, bidycode varchar(10) Not Null ,
room varchar(6) Not Null , Capacity Numeric(5) Not Null)" " "
cursor.execute(sql)
db.close()
23. i. 'World'
ii. 'Hello'

OR

24. ('ABC', 35000)


25. Output
a : 175
b : 15
x : 50
y : 25
z : 100

OR

The length of this tuple is 3 because there are just three elements in the given tuple. Because a careful look at the given
tuple yields that tuple t is made up of:
t1 = "a", 1

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


11 / 18
myCBSEguide
t2 = t1, "b", "c"
t3 = t2, "d", 2
t = (t3, "e", 3)

26. def Readfile():


i=open("Employee.dat", "rb+")
x=i.readline()
while(x):
l=x.split(':')
if (20000>=float(1[2])<=40000):
print(x)
x=i.readline()

OR

def count_Dwords():
with open ("Details.txt", 'r') as F: # ignore 'r'
S=F.read()
Wlist = S.split()
count = 0
for w in wlist:
if w [-1].isdigit():
count+=1
print ("Number of words ending with a digit are", count)

OR

def count_Dwords():
count=0
myfile=open("Details.txt")
S=myfile.read()
Wlist=S.split()
for W in Wlist:
if i[-1] in "0123456789":
count=count+1
myfile.close()
print("Number of words ending with a digit are",count)

27. In Python, a default parameter is defined with a fallback value as a default argument. Such parameters are optional
during a function call. If no argument is provided, the default value is used, and if an argument is provided, it will
overwrite the default value. greet("Ankit", "How do you do?")
28. There are mainly two types of duplex communication:
i. Full duplex: In this type of transmission, two bitstreams can be simultaneously transmitted over the links at the same
time, one going in each direction, i.e., sending as well as receiving the data. For example, in a telephone
conversation, two people communicate, and both are free to speak and listen at the same time.
ii. Half-duplex: In this type of transmission, data can flow in only one direction at a time i.e., either sending or
receiving data at a time. For example, in walkie-talkies, the speakers at both ends can speak, but they have to speak

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


12 / 18
myCBSEguide
one by one. They cannot speak simultaneously.
Section C
29. def prime(n) :
for num in range (2, n) :
is_prime = 1
for i in range (2, num):
if num % i == 0:
is_prime = 0
if is_prime == 1:
print (num)

OR

def InsertQ(Names):
Name=raw_input("enter Name to be inserted: ")
Names.append(Name)
def DeleteQ(Names):
if (Names==[]):
print "Queue empty"
else:
print "Deleted Player’s Name is: ",Names[0]
del(Names[0])

30. a. SELECT Name, Age FROM VACCINATION_DATA WHERE DOSE2 IS NOT NULL AND Age > 40;
Name Age

Harjot 55

Srikanth 43
b. SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
City COUNT(*)

Delhi 2

Mumbai 2
Kolkata 1
c. SELECT DISTINCT CITY FROM VACCINATION_DATA;
CITY

Delhi
Mumbai

Kolkata
d. SELECT MAX(Dose1), MIN(Dose2) FROM VACCINATION_DATA;
MAX(Dose1) MIN(Dose2)

2022-01-01 2021-07-20

OR

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


13 / 18
myCBSEguide
MySQL is a free, open-source Relational Database Management System (RDBMS) that uses Structured Query Language
(SQL). In a MySQL database, information is stored in Tables. A single MySQL database can contain many tables at
once and store thousands of individual records.
31. The differences between a local variable and a global variable are as given below :
Local Variable Global Variable
1. It is a variable which is declared within a function or within a 1. It is a variable which is declared outside all the
block functions

2. It is accessible only within a function/block in which it is


2. It is accessible throughout the program
declared
3.Local variables are created when the function has started 3.Global variable is created as execution starts
execution and are lost when the function terminates. and is lost when the program ends.

For example, in the following code, x, xCubed are global variables and n and cn are local variables.
def cube(n):
cn = n * n * n
return cn
x = 10
xCubed = cube(x)
print(x, "cubed is", xCubed)

OR

def OddSum(NUMBERS) :
odd_sum = 0
for num in range (len(NUMBERS)):
if (NUMBERS[num] % 2 != 0:
odd_sum = odd_sum + NUMBERS [num]
print odd_sum
Section D
32. " " "
Stack: implemented as a list
top: integer having a position of a topmost element in Stack
"""
def cls( ):
print("\n"* 100)
def is Empty(stk) :
if stk== [ ] :
return True
else :
return False
def Push(stk, item) :
stk.append(item)
top = len(stk) - 1
def Display(stk) :
if isEmpty(stk) :
print ("Stack empty”)

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


14 / 18
myCBSEguide
else :
top = len(stk) - 1
print(stk[top], "<-top")
for a in range(top-1, -1, -1 ) :
print(stk[a])
# __main__
Stack = [] # initially stack is empty
top = None
while True :
cls()
print ("STACK OPERATIONS")
print("1. Push operation")
print("2. Display stack")
print("3. Exit")
ch = int(input("Enter your choice (1-5) :"))
if ch == 1 :
bno = int(input("Enter Book no. to be inserted :"))
bname = input ("Enter Book name to be inserted :")
item = [bno, bname] # creating a list from the input items.
PushfStack, item)
input()
elif ch == 2 :
Display(Stack)
input( )
elif ch == 3 :
break
else :
print("Invalid choice!")
input()

OR

MAX_SIZE = 1000
stack = [0 for i in range(MAX_SIZE)]
top = 0
def isEmpty ( ):
global top
return top == 0
def push(x):
global stack,top
if top >= MAX_SIZE:
return
stack[top]= x
top += 1
def pop( ):
global stack,top
if isEmpty( ):

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


15 / 18
myCBSEguide
return
else:
top -= 1
return stack[top]
string = input( ).split()
for i in string:
push(i)
while not isEmpty( ):
x = pop( )
print (x + x, end = ' ')

33. def countrec():


try:
# Open the binary file in read mode
with open("PATIENTS.dat", "rb") as file:
covid_patients = [] # List to store COVID-19 patients
total_covid_patients = 0
while True:
record = file.readline().decode().strip()
if not record:
break
PID, NAME, DISEASE = record.split(",")
if DISEASE == "COVID-19":
covid_patients.append((PID, NAME))
total_covid_patients += 1
# Display details of COVID-19 patients
print("Details of COVID-19 patients:")
for pid, name in covid_patients:
print(f"PID: {pid}, NAME: {name}")
print(f"Total COVID-19 patients: {total_covid_patients}")
except FileNotFoundError:
print("File 'PATIENTS.dat' not found.")
# Call the function
countrec()

34. i. SELECT NAME FROM DOCTOR WHERE DEPT='MEDICINE' AND EXPERIENCE > 10;
ii. SELECT AVG(BASIC + ALLOWANCE) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM
DOCTOR WHERE DEPT='ENT');
iii. SELECT MIN(ALLOWANCE) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM DOCTOR WHERE
SEX ='F');
iv. SELECT MAX(CONSULTATION) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM DOCTOR
WHERE SEX='M');
v. SELECT * FROM DOCTOR
WHERE EXPERIENCED>12;

OR

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


16 / 18
myCBSEguide
i. SELECT * FROM CLIENT
WHERE City = ' Delhi ' ;
ii. SELECT * FROM PRODUCT
WHERE Price BETWEEN 50 AND 100 ;
iii. SELECT ClientName, City, ProductName, Price
FROM CLIENT, PRODUCT
WHERE CLIENT.P_ID = PRODUCT.P_ID ;
iv. UPDATE PRODUCT
SET Price = Price + 10 ;
35. def encrypt(sttr, enkey):
return enkey.join(sttr)
def decrypt(sttr, enkey):
return sttr.split(enkey)
#-main-
mainstring = input("Enter main string:")
encryptStr = input("Enter encyption key:")
enStr = encrypt(mainString, encryptStr)
deLst = decrypt(enStr, encryptStr)
# deLst is in the form of a list, converting it to string below
deStr="".join(deLst)
print("The encrypted string is", enStr)
print("String after decryption is:", deStr)
The sample run of the above program is as shown below:
Enter main string : My main string
Enter encryption key : @T heencryptedstringism@ y@@ m@a@i@n@ @s@t@r@i@n@ g
String after decryption is : My main string
Section E
36. i. The server should be Dedicated server
ii. The most suitable place to house the server is Science Block as it has the maximum number of computers. Thus,
reducing the cabling cost and increase the efficiency of the network.
iii. SWITCH
iv. Satellite Connection Or Leased line
37. i. SELECT * FROM MEMBER ORDER BY ISSUEDATE DESC
ii. SELECT Code, BNAME FROM BOOK WHERE TYPE 'Fiction'
iii. SELECT COUNT(*), TYPE FROM BOOK GROUP BY TYPE
iv. SELECT MNAME, ISSUEDATE FROM MEMBER WHERE ISSUEDATE Like '2017 %'
v. MAX (ISSUE DATE) 2017-02-23
vi. DISTINCT (TYPE)
Fiction
Literature
Comic

vii. CODE BNAME MNO MNAME

L102 German easy M101 RAGHAV SINHA

F102 Untold Story M103 SARTHAK JOHN


C101 Tarzan in the lost world M102 ANISHA KHAN

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


17 / 18
myCBSEguide
viii. BNAME
German easy

OR

i. 4

ii. 35 12
iii. Invalid query
iv. SX4
C Class
To practice more questions & prepare well for exams, download myCBSEguide.com App. It provides complete
study material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8.com App to
create similar papers with their own name and logo.

Copyright © myCBSEguide.com. Mass distribution in any mode is strictly prohibited.


18 / 18

You might also like