Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutions

In this article, we will discuss Answer Key Computer Science Class 12 Board Paper 2023. If you have appeared for the board exam 2023, this article provides suggested answers for Computer Science Board Question paper. So here we go!

Computer Science Class 12 Board Paper 2023 Answer Key

CBSE Computer Science Class 12 Board Exam 2023 was conducted on 23.03.2023 as per schedule. So here I will discuss some suggested answers for the questions asked in the board exam 2023. This is not an official answer key but suggested answers prepared after healthy discussion with subject experts in the community. So here we go!

The Computer Science Class 12 Board Paper 2023 is a purely based sample paper provided by CBSE board. It has the following sections:

SectionQuestion Type and No. of QuestionsNo. of Questions and Marks of Each QuestionTotal Marks of Question
AObjective Type Questions18 X 118
BVery Short Answer Type Questions7 X 2 14
CShort Answer Type Questions5 X 315
DLong Answer Type Questions3 X 515
ECase Study-Based Questions2 X 48
Total3570

Let us begin the discussion of Answer Key Computer Science Class 12 Board Paper 2023. Here we go!

Download the board question paper of computer science for class 12 from this link.

Computer Science Class 12 question paper 2023 PDF

Section A – Answer Key Computer Science Class 12 Board Paper 2023

Section A – Answer Key Computer Science Class 12 Board Paper 2023 contains 18 MCQs and 1-mark question. So here we begin!

[1] State True or False.
“Identifiers are names used to identify a variable, function in a program”.

[2] Which of the following is a valid keyword in Python?
a) false

b) return

c) non_local

d) none

[3] Given the following Tuple: Tup= (10, 20, 30, 50)                             

Which of the following statements will result in an error?

(a) print (Tup [0] )

(b) Tup . insert (2, 3)

(c) print (Tup [1 : 2] )

(d) print (len (Tup) )

[4] Consider the given expression :

5<10 and 12>7 or not 7>4

Which of the following will be the correct output, if the given expression is evaluated?             

(a) True  

(b) False

(c) NONE 

(d) NULL

[5] Select the correct output of the code:                                        

S= “Amrit Mahotsav @ 75”

A=S . partition(” “)

print(a)

(a) (‘Amrit Mahotsav’,’@’,’ 75 ‘ )

(b) [ ‘Amrit’ , ‘Mahotsav’ ,’@’,’ 75 ‘ ]

(c) ( ‘ Amrit’, ‘Mahotsav @ 75 ‘ )

(d) ( ‘Amrit’ ,’  ‘, ‘Mahotsav @ 75 ‘ )

[6] Which of the following mode keeps the file offset position at the end of the file?                              1

(a) r+

(b) r

(c) w

(d) a

[7] Fill in the blank.                                                                 

Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutions___________________ function is used to arrange the elements of a list in ascending order.

Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutions(a) sort ( )

(b) arrange ( )

(c) ascending ( )         

(d) asort ( )

[8] Which of the following operators will return either True or False?   

(a) +=

(b) !=

(c) =

(d) *=

[9] Which of the following statement(s) would give an error after executing the following code?          

Stud= { "Murugan" : 100, "Mithu" : 95} # Statement 1
print (Stud [95] )  # Statement 2
Stud [ "Murugan " ] =99  # Statement 3  
print (Stud. pop ( ) ) # Statement 4
print (Stud)     # Statement 5

(a) Statement 2          

(b) Statement 3          

(c) Statement 4          

(d) Statements 2 and  4

[10] Fill in the blank.                                                                  

_____________ is a number of tuples in a relation.

(a) Attribute

(b) Degree

(c) Domain  

(d) Cardinality

[11] The syntax of seek( ) is                                               

file object.seek (offset[, reference point] )

What is the default value of reference point ?

(a) 0

(b) 2

(c) 1

(d) 3

[12] Fill in the blank                                                             

__________ clause is used with SELECT statement to display data in a sorted form with respect to a specified column.

(a) WHERE

(b) ORDER BY

(c) HAVING                                         

(d) DISTINCT

[13] Fill in the blank                                                                         1

____________ is used for point-to-point communication or unicast communication such as radar and satellite.

(a) INFRARED WAVES   

(b) BLUETOOTH

(c) MICROWAVES 

(d) RADIOWAVES

[14] What will the following expression be evaluated to in Python?      

print (4+3*5/3-5%2)

(a) 8 . 5      

(b) 8 . 0

(c) 10 .2     

(d) 10 . 0

[15] Which function returns the sum of all elements of a list?        

(a) count ( )

(b) sum ( )

(c) total ( )  

(d) add ( )

[16] fetchall() method fetches all rows in a result set and returns a :  

(a) Tuple of lists   

(b) List of tuples

(c) List of strings  

(d) Tuple of strings

Q. 17 and 18 are ASSERTION (A) and REASONING (R) based questions.Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutions 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) : To use a function from a particular module, we need to Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutionsimport the module.   

Reason (R) : import statement can be written anywhere in the program, before using a function from that module.

[18] Assertion (A) : A stack is a LIFO structure.                                       

Reason (R) : Any new element pushed into the stack always gets positioned at the index after the last existing element in the stack.

Section B Computer Science Class 12 Board Paper 2023 Answer Key

In section B Answer Key Computer Science Class 12 Board Paper 2023 contains 7 questions of 2 marks. Let’s have a look!

[19] Atharva is a Python programmer working on a program to find and return the maximum value from the list. The code written below has syntactical errors. Rewrite the correct code and underline the corrections made.                      2

def max_num (L):
         max=L (0)
         for a in L :
                if a > max
                    max=a
        return max

Ans.:

def max_num (L):
         max=L[0]   or max=0
         for a in L :
                if a > max: #Colon is missing
                    max=a
        return max

[20] (a) Differentiate between wired and wireless transmission.

Ans.:

WiredWireless Transmission
Data transmission done using physical media (wires/cables)Data transmission is done using waves and air
No antenna is requiredIt requires antenna at both ends
Information sent in form of electronic signalsInformation sent in form of waves
It is mostly suitable for a short distanceIt is mostly suitable for long distance
It is quite easy to maintain and configureIt is quite complex to maintain and configure

OR

(b) Differentiate between URL and domain name with the help of an appropriate example.

Ans.:

URLDomain Name
It is a complete web address for a website.It is like a brand name for a web site.
It contains complete domain name.It is a part of the URL.
It is made up of protocol, domain name, port, and path of the file.It is made up of the name and top-level domain of a particular website
Example: https:\\www.tutorialaicsip.com\Example: tutorialaicsip.com

[21] (a) Given is a Python list declaration :                                             

Listofnames= [ “Aman ” , “Ankit ” , “Ashish” , “Rajan” , “Rajat ” ]

Write the output of :

print (Listofnames [-1:-4:-1])

(b) Consider the following tuple declaration :                              

tupl= (10, 20, 30, (10,20,30), 40)

Write the output of :

print (tupl . index (20) )

Ans.:

a)

Ans.: [‘Rajat ‘, ‘Rajan’, ‘Ashish’]

Explanation:

ElementAmanAnkitAshishRajanRajat
Index-5-4-3-2-1

Now, the slicing starts with -1 i.e. Rajat, and Stops at -4 Ankit but do not consider Ankit with step -1.

b)

Ans.: 1

Explanation:

The index() method will return the index position of the first occurrence of a specified value from the sequence such as a list or tuple. So here first of 20 is at index 1.

Element102030(10,20,30)40
Index01234

[22] Explain the concept of “Alternate Key’ in a Relational Database Management System with an appropriate example. 

Ans.: In DBMS, the alternate keys are those candidate keys that are not primary keys.

For example:

Consider the table student as follows:

FieldKey
RollnoPrimary Key
Name
EmailAlternate Key
Contact_noAlternate Key

The above table has three candidate keys (Rollno, Email, Contact_no) as they may have unique values. So these columns are candidate keys for table student. Now, rollno field is assigned as the primary key so the left candidate keys become alternate keys i.e. Email and Contact_no.

[23] (a) Write the full forms of the following :                                      

  1. HTML
  2. TCP

(b) What is the need of protocols?

Ans.:

(a) 1. HTML – Hyper Text Markup Language

2. TCP – Transmission Control Protocol

(b) Network protocols allow communication between various types of networks.

[24] (a) Write the output of the code given below :

def short_sub (lst,n):
  for i in range (0,n):
    if len (lst) >4:
      lst [i] =lst [i]+lst [i]
    else:
      lst [i]=lst [i]
subject=['CS', 'HINDI', 'PHYSICS', 'CHEMISTRY', 'MATHS']
short_sub (subject, 5)
print (subject)

Ans.: [‘CSCS’, ‘HINDIHINDI’, ‘PHYSICSPHYSICS’, ‘CHEMISTRYCHEMISTRY’, ‘MATHSMATHS’]

Explanation:

In the function, for loop iterates 5 times, and every time it checks the length of lst list which is 5. So with every iteration if the condition evaluates to True. It will never go to check else block. Hence the element will be concatenated with itself.

OR

(b) Write the output of the code given below:

a=30
def call (x):
  global a
  if a%2==0:
    x+=a
  else:
    x-=a
  return x
x=20
print (call (35), end="#")
print (call (40),end= "@")

Ans.: 65#70@

Explanation:

a=30

x=20

call(35)

global a = 30

30%2=0 – True

x=x+a=35+30=65

call(40)

global a = 30

30%2=0 – True

x=x+a=40+30=70

Hence Ouptut is : 65#70@

[25] (a) Differentiate between CHAR and VARCHAR data types in SQL with appropriate example.      

Ans.:

CharVarchar
It stores the fixed-size stringIt stores the variable length string
It occupies fix amount of storageThe amount of storage is varying based on the string stored
It offers better performanceSlightly poor performance due to various length
It pads spaces to the right when storing string less than fixed size lengthIt pads spaces to the right when storing string less than a fixed size length
Example: If a column student_id has char data type with size 5 and values are S0001, S0002, S0003, S0004, and S0005 then every cell stores fixed length size i.e. 5. Example: If a column student_name has values like SAM, KARAN, AJAY and VIJAY then it stores 3, 5, 4, and 5 respectively.

OR

(b) Name any two DDL and any two DML commands.                           

Ans.: DDL: Create, Alter, and Drop

         DML: Insert, Update, and Delete

Section C – Computer Science Class 12 Board Paper 2023 Answer Key

This section of Answer Key Computer Science Class 12 Board Paper 2023 consists of 3 marks questions. This section of Answer Key Computer Science Class 12 Board Paper 2023 contains 5 questions with internal choices from 26 to 30.

[26] (a) Consider the following tables — LOAN and BORROWER:

Table : LOAN

LOAN_NOB_NAMEAMOUNT
L-170DELHI3000
L-230KANPUR4000

Table : BORROWER

CUST_NAMELOAN_NO
JOHNL-171
KRISHL-230
RAVYAL-170

How many rows and columns will be there in the natural join of these two tables?

(b) Write the output of the queries (i) to (iv) based on the table, WORKER given below:

TABLE: WORKER

 F_NAMEL_NAMECITYSTATE
102SAHILKHANKANPURUTTAR PRADESH
104SAMEERPARIKHROOP NAGARPUNJAB
105MARYJONESDELHIDELHI
106MAHIRSHARMASONIPATHARYANA
107ATHARVABHARDWAJDELHIDELHI
108VEDASHARMAKANPURUTTAR PRADESH
  1. SELECT F_NAME, CITY FROM WORKER ORDER BY STATE DESC;
  2. SELECT DISTINCT (CITY) FROM WORKER;
  3. SELECT F_NAME, STATE FROM WORKER WHERE L_NAME LIKE ‘_HA%’
  4. SELECT CITY, COUNT(*) FROM WORKER GROUP BY CITY;

Ans.:

a) Number of rows is 2 and the columns are 4.

Explanation:

Natural join displays all rows and matched columns of two tables. The column with same name will be displayed just once.

b)

(i)

F_NAMECITY
SAHILKANPUR
VEDAKANPUR
SAMEERROOP NAGAR
MAHIRSONIPAT
MARYDELHI
ATHARVADELHI

(II)

CITY
KANPUR
ROOP NAGAR
DELHI
SONIPAT

(iii)

F_NAMESTATE
SAHILUTTAR PRADESH
MAHIRHARYANA
ATHARVADELHI
VEDAUTTAR PRADESH

(iv)

CITYCOUNT(*)
KANPUR2
ROOP NAGAR1
DELHI2
SONIPAT1

[27] (a) Write the definition of a Python function named LongLines( ) which reads the contents of a text file named ‘LINES . TXT’ and displays those lines from the file which have at least 10 words in it.

For example, if the content of ‘ LINES . TXT ‘ is as follows :                                                               3

Once upon a time, there was a woodcutter

He lived in a little house in a beautiful, green wood.

One day, he was merrily chopping some wood.

He saw a little girl skipping through the woods, whistling happily.

The girl was followed by a big gray wolf.

Then the function should display output as :

He lived in a little house in a beautiful, green wood.

He saw a little girl skipping through the woods, whistling happily.

Ans:

def LongLines():
  f=open("lines.txt")
  dt=f.readlines()
  for i in dt:
    if len(i.split())>10:
      print(i)
  f.close()
LongLines()

OR

(b) 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 VIP 1 will sit and

On seat1 VVIP2 will be sitting

Output will be:

Number of words ending with a digit are 4

def Dwords():
  f=open("details.txt")
  dt=f.read()
  w=dt.split()
  c=0
  for i in w:
    if i[-1].isdigit():
      c+=1
  print("Number of words ending with digit are:",c)
Dwords()

[28] (a) Write the outputs of the SQL queries (i) to (iv) based on the relations COMPUTER and SALES given below :            

Table : COMPUTER

PROD_IDPROD_NAMEPRICECOMPANYTYPE
P001MOUSE200LOGITECHINPUT
P002LASER PRINTER4000CANONOUTPUT
P003KEYBOARD500LOGITECHINPUT
P004JOYSTICK1000IBALLINPUT
P005SPEAKER1200CREATIVEOUTPUT
P006DESKJET PRINTER4300CANONOUTPUT

Table : SALES

PROD_IDQTY_SOLDQUARTER
P00241
P00322
POOI32
P00421
  1. SELECT MIN (PRICE) , MAX (PRICE) FROM COMPUTER;
  2. SELECT COMPANY, COUNT FROM COMPUTER GROUP BY COMPANY HAVING COUNT (COMPANY) > 1;
  3. SELECT PROD NAME, QTY SOLD FROM COMPUTER C, SALES S WHERE C. PROD ID=S.PROD ID AND TYPE =
  4. SELECT PROD NAME, COMPANY, QUARTER FROM COMPUTER C, SALES S WHERE C. PROD ID=S. PROD ID;

(b) Write the command to view all databases. 

Ans.:

(i)

MIN(PRICE)MAX(PRICE)
2004300

(ii)

COMPANYCOUNT(*)
LOGITECH2
CANON2

(iii)

PROD_NAMEQTY_SOLD
KEYBOARD2
MOUSE3
JOYSTICK2

(iv)

PRDO_NAMECOMPANYQUARTER
LASER PRINTERCANON1
KEYBOARDLOGITECH2
MOUSELOGITECH2
JOYSTICKIBALL1

(b) show databases;

[29] Write a function EOReplace() in Python, which accepts a list L of numbers. Thereafter, it increments all even numbers by 1 and decrements all odd numbers by 1.

Example
If Sample Input data of the list is
L=[10,20,30, 40, 35, 55]
Output will be :
L=[11,21,31, 41, 34, 54]

Ans.:

def EOReplace(L):
  for i in range(len(L)):
    if L[i]%2!=0:
      L[i]-=1
    else:
      L[i]+=1
  return L 
L=eval(input("Enter List:"))
print(EOReplace())

[30] (a) A list contains the following record of customer: [Customer_name, Room Type]
Write the following user-defined functions to perform given operations on the stack named ‘ Hotel’:
i) Push_Cust () – To Push customers names of those customers who are staying in Delux’ Room Type.
ii) Pop_Cust ()- To Pop the names of customers from the stack and display them. Also, display “Underflow” when there are no customers in the stack.
For example:
If the lists with customer details are as follows:
[“siddarth”, “Delux”]
[“Rahul”, “Standard”]
[“Jerry”, “Delux”]
The stack should contain
Jerry
Siddharth

The output should be:
Jerry
Siddharth
Underflow

Ans.:

customer=[["Siddarth", "Delux"], ["Rahul", "Standard"], ["Jerry", "Delux"]]
hotel=[]
def push_cust():
  for i in customer:
    if i[1]=='Delux':
      hotel.append(i[0])
  return hotel

def pop_cust():
  if hotel==[]:
    return "Underflow"
  else:
    return hotel.pop()

push_cust()
while True:
  if hotel==[]:
    print(pop_cust())
    break
  else:
    print(pop_cust())

OR

b) Write a function in Python, Push (Vehicle) where, Vehicle is a dictionary containing details of vehicles – {Car_Name: Maker}.
The function should push the name of car manufactured by “TATA’ (including all the possible cases like Tata, TaTa, etc.) to the stack.
For example:
If the dictionary contains the following data:
Vehicle={“Santro” : “Hyundai”, “Nexon”: “TATA”, “Safari” : “Tata”}
The stack should contain
Safari
Nexon

Ans.:

Vehicle={"Santro" : "Hyundai", "Nexon": "TATA", "Safari" : "Tata"}
stk=[]
def push(vehicle):
  for i in vehicle:
    if vehicle[i].lower()=='tata':
      stk.append(i)
  return stk

push(Vehicle)
for i in range(-1,-len(stk)-1,-1):
  print(stk[i])

Section D – Computer Science Class 12 Board Paper 2023 Answer Key

Section D of Answer Key Computer Science Class 12 Board Paper 2023 contains 5 marks questions. There are 3 questions a student has to answer. Here we go!

[31] Quickdev, an IT based firm, located in Delhi is planning to set up a network for its four branches within a city with its Marketing department in Kanpur. As a network professional, give solutions to questions (i) to (v), after going through the branches’ locations and other details which are given below:

Answer Key Computer Science Class 12 Board Paper 2023 PDF Easy Complete Solutions

Distance between various branches is as follows:

BranchDistance
Branch A to Branch B40 m
Branch A to Branch C80 m
Branch A to Branch D65 m
Branch B to Branch C30 m
Branch B to Branch D35 m
Branch C to Branch D15 m
Delhi Branch to Kanpur300 km

Number of computers in each of the branches:

BranchNumber of computers
Branch A15
Branch B25
Branch C40
Branch D115

(i) Suggest the most suitable place to install the server for the Delhi branch with a suitable reason.

(ii) Suggest an ideal layout for connecting all these branches within Delhi.

(iii) Which device will you suggest, that should be placed in each of these branches to efficiently connect all the computers within these branches?
iv) Delhi firm is planning to connect to its Marketing department in Kanpur which is approximately 300 km away. Which type of network out of LAN, WAN or MAN will be formed ? Justify your answer.
(v) Suggest a protocol that shall be needed to provide help for transferring of files between Delhi and Kanpur branch.

Ans.:

(i) As per 80-20 rule, the most suitable place to install the sever for the Delhi branch is Branch D because it contains a maximum number of computers.

(ii)

cable layout for branches of Delhi - computer science class 12 paper 2023

(iii) Switch should be placed in each of these branches to efficiently connect all the computers within these branches.

(iv) WAN as the limit is more than 100 kms.

(v) To transfer files from Delhi to Kanpur branch, FTP is the best protocol

[32] (a) What possible output(s) are expected to be displayed on screen at the time of execution of the following program:

import random
M=[5,10,15,20,25,301]
for i in range (1,3):
   first=random. randint (2,5) - 1
   sec=random.randint (3, 6) - 2
   third=random.randint (1,4)
   print (M[ first],M[sec],M[third], sep="#")


i) 10#25#15
20#25#25
ii) 5#25#20
25#20#15
iii) 30#20#20
20#25#25

iv) 10#15#25#
15#20#10#

Ans.:

(i) and (ii) both are expected outputs.

Explanation:

First=(2,5)-1 refers 2-1=1,2,3,4

Second=(3-6)-2 refers 3-2=1,2,3,4

Third = 1,2,3,4

Hence values between 10,15,20 and 35 are expected as output in iteration.

b) The code given below deletes the record from the table employee which contains the following record structure

E_code – String
E_name – String
Sal – Integer
City – String
Note the following to establish connectivity between Python and MySQL:

  • Username is root
  • Password is root
  • The table exists in a MySQL database named emp.
  • The details (E_code, E_name, Sal, City) are the attributes of the table.

Write the following statements to complete the code:

  1. Statement 1 – to import the desired library.
  2. Statement 2 – to execute the command that deletes the record with E_code as ‘E101’.
  3. Statement 3 – to delete the record permanently from the database.
import ______________ as mysql # Statement 1
def delete ():
  mydb=mysql.connect (host="localhost", user="root", passwd="root", database="emp")
  mycursor=mydb.cursor( )
  __________ # Statement 2
  __________ #Statement 3
  print ("Record deleted")

Ans.:

  1. mysql.connector
  2. mycursor.execute(“delete from employee where e_code=’E101′ “)
  3. mydb.commit()

OR

(a) Predict the output of the code given below:

def makenew (mystr):
  newstr=""
  count=0
  for i in mystr:
    if count%2!=0:
      newstr=newstr+str (count)
    else:
      if i.lower ():
        newstr=newstr+i.upper ()
      else:
        newstr=newstr+i
    count+=1
  print (newstr)
makenew("No@1")

Ans.:

N1@3

Explanation:

makenew(No@1)

count=0

i=0

count%2!=0

o=1 and 3 remains 3 only

count%2==0

N remains same, @ remains same

(b) The code given below reads the following records from the table employee and displays only those records who have employees coming from city Delhi’:
E_code – String
E_name – String
Sal – Integer
City – String

Note the following to establish connectivity between Python and MySQL:

  • Username is root
  • Password is root
  • The table exists in a MySQL database named emp.
  • The details (E_code, E _name, Sal, City) are the attributes of the table.

Write the following to establish connectivity between Python and MySQL:

  1. Statement 1 – to import the desired library.
  2. Statement 2 – to execute the query that fetches records of the employees coming from the city ‘Delhi’.
  3. Statement 3– to read the complete data of the query (rows whose city is Delhi) into the object named details, from the table employee in the database.
import ______ as mysql #Statement 1
def display () :
  mydb=mysql.connect (host="localhost", user="root",
  passwd="root", database="emp")
  mycursor=mydb.cursor ()
  ________________#Statement 2
  details = ______#Statement 3
  for i in details:
    print (i)

Ans.:

  1. mysql.connector
  2. mycursor.execute(“select * from employee where city=’Delhi'”)
  3. fetchall()

33. (a) Write one difference between CSV and text files.

Write a program in Python that defines and calls the following user-defined functions:

  1. COURIER_ ADD(): It takes the values from the user and adds the details to a csv file ‘courier.csv’. Each record consists of a list with field elements as a cid, s_name, Source and destination to store Courier ID, Sender name, Source and destination address respectively.
  2. COURIER_SEARCH (): Takes the destination as the input and displays all the courier records going to that destination.

Ans.:

a) CSV file represents data in a tabular form separated by a comma, and textfiles represent data in plain text form.

import csv
def COURIER_ADD():
  f=open("courier.csv","a",newline='')
  wo=csv.writer(f)
  cid=input("Enter Courier ID:")
  s_name=input("Enter Sender Name:")
  source=input("Enter Source:")
  destination=input("Enter Destination:")
  wo.writerow([cid,s_name,source,destination])
  f.close()

def COURIER_SEARCH():
  f=open("courier.csv",'r')
  ro=csv.reader(f)
  de=input("Enter desitination:")
  for i in ro:
    if i[3]==de:
      print("Courier ID:",i[0])
      print("Sender:",i[1])
      print("Source:",i[2])
      print("Destination:",i[3])
COURIER_ADD()
COURIER_SEARCH()

OR

b) Why it is important to close a file before exiting?

Write a program in Python that defines and calls the following user-defined functions :

i) Add_Book(): Takes the details of the books and adds them to a csv file ‘Book.csv‘. Each record consists of a list with field elements as book_ID, B_ name and pub to store book ID, book name and publisher respectively.
ii) Search_Book(): Takes publisher name as input and counts and displays the number of books published by them.

Ans.:

a) Files are a limited resource managed by the OS, so it is important to close them to avoid reaching the open limit and impacting program performance. Files left unintentionally open become vulnerable to loss of data, and changes to files cannot be readable until closed.

import csv
def Add_Book():
  f=open("book.csv","a",newline='')
  wo=csv.writer(f)
  book_id=input("Enter Book ID:")
  b_name=input("Enter Book Name:")
  pub=input("Enter Publisher:")
  wo.writerow([book_id,b_name,pub])
  f.close()

def Search_Book():
  f=open("book.csv",'r')
  ro=csv.reader(f)
  pn=input("Enter Publisher:")
  cnt=0
  for i in ro:
    if i[2]==pn:
      cnt+=1
      print("Book ID:",i[0])
      print("Book:",i[1])
      print("Publisher:",i[2])
  print("Total Books Published by ",pn," are:",cnt)
Add_Book()
Search_Book()

Section E – Answer Key Computer Science Class 12 Board Paper 2023

Section E is the last section of Answer Key Computer Science Class 12 Board Paper 2023. It contains 2 questions of 4 marks. Let’s have a look!

[34] The school has asked their estate manager Mr. Rahul to maintain the data of all the labs in a table LAB. Rahul has created a table and entered data of 5 labs.

LABNOLAB_NAMEINCHARGECAPACITYFLOOR
L001CHEMISTRYDaisy20I
L002BIOLOGYVenky20II
L003MATHPreeti15I
L004LANGUAGEDaisy36III
L005COMPUTERMary Kom37II

Based on the data given above answer the following questions:

  1. Identify the columns which can be considered as Candidate keys.
  2. Write the degree and cardinality of the table.
  3. Write the statements to :
    • Insert a new row with appropriate data.
    • Increase the capacity of all the labs by 10 students which are on I Floor.

OR

(Option for Part (3) only)

3. Write the statements to:
(a) Add a constraint PRIMARY KEY to the column LABNO in the table.

b) Delete the table LAB.

Ans.:

  1. LABNO and LABNAME columns can be considered as candidate keys because they can be the primary key of the table. The reason behind this is they have unique records.
  2. Degree:5, Cardinality:5
  3. Write Statements to:
    • insert into LAB values(‘L006′,’PHYSICS’,’Kane’,40,’I’);
    • update LAB set capacity=capacity+10 where floor=’I’;

OR

3. Write Statements to

a) alter table LAB add primary key (LABNO);

b) Drop table LAB;

[35] Shreyas is a programmer, who has recently been given a task to write a user defined function named write_bin () to create a binary file called Cust_file.dat containing customer information – customer number
(c_no), name (c_name), quantity (qty), price (price) and amount (amt) of each customer.

The function accepts customer number, name, quantity and price. Thereatter, it displays the message ‘Quantity less than 10… Cannot SAVE’, if quantity entered is less than 10. Otherwise the function calculates amount as price * quantity and then writes the record in the form of a list into the binary file.

import pickle
def write bin () :
  bin_file=_______ #Statement 1
  while True:
    c_no=int (input ("enter customer number")
    c name=input ("enter customer name")
    gty-int (input ("enter qty"))
    priceint (input ("enter price") )
    if _________ #Statement 2
      print ("Quantity less than 10..Cannot AVE")
    else:
      amt=price * gty
      c_detail=[c_no,c_name, qty, price, amt]
      __________ #Statement 3
      ans=input ("Do you wish to enter more records y/n")
      if ans.lower ()=='n':
        ________#Statement 4
      ________#Statement 5
 ________#Statement 6
  1. Write the correct statement to open a file ‘Cust_file.dat‘ for writing the data of the customer.
  2. Which statement should Shreyas fill in Statement 2 to check whether quantity is less than 10.
  3. Which statement should Shreyas fill in Statement 3 to write data to the binary file and in Statement 4 to stop further processing if the user does not wish to enter more records.

OR
(Option for part (3) only)

3. What should Shreyas fill in Statement 5 to close the binary file named Cust_file.dat and in Statement 6 to call a function to write data in binary file ?

Ans.:

  1. open(“Cust_file.dat”,”ab”)
  2. qty<10:
  3. pickle.dump(l,bin_file); break

OR

3. bin_file.close(); write_bin()

Download Answer Key Computer Science Class 12 Board Paper 2023

Follow this link to download answer key for Computer Science Class 12 Board Paper 2023.

Answer Key Computer Science Class 12 Board Paper 2023

That’s all from Answer Key Computer Science Class 12 Board Paper 2023. I hope this will help you to understand the complete answers for Answer Key Computer Science Class 12 Board Paper 2023.

Share this link with your friends to help them to get the Answer Key Computer Science Class 12 Board Paper 2023. Feel free to share your feedback, views, or opinion about this article Answer Key Computer Science Class 12 Board Paper 2023.

Thank you for reading this article – Answer Key Computer Science Class 12 Board Paper 2023.

Leave a Reply