12 CS PB1 Hyd QP MS B
12 CS PB1 Hyd QP MS B
(2024-25)
CLASS-12
SUBJECT-COMPUTER SCIENCE (083)
MARKING SCHEME
Time Allowed: 3 hours Maximum Marks: 70
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 21 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 04 Short Answer type questions carrying 03 marks each.
6. Section D has 02 Long Answer type questions carrying 05 marks each.
7. Section E has 03 questions carrying 04 marks each.
8. All programming questions are to be answered using Python Language only.
SECTION-A
S.No Question Marks
1 What is the return type of function id? 1
a) int b) float c) bool d) dict
Ans: a) int
2 What error occurs when you execute? 1
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
Ans: b) NameError
3 Carefully observe the code and give the answer. 1
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
a) indentation Error
b) cannot perform mathematical operation on strings
c) hello2
d) hello2hello2
Ans: a) indentation Error
4 Aryan created a table (Students) with 5 rows and 6 columns. After few days based on the 1
requirement he added 3 more rows to the table. What is the cardinality and degree of the table?
a) cardinality=6,degree=8
b) cardinality=8,degree=6
c) cardinality=5 degree=8
d) None of the above
Ans: b) cardinality=8,degree=6
5 What is the output of the following? 1
print("xyyzxyzxzxyy".count('xyy', 0, 100))
a) 2
b) 0
c) 1
d) error
Ans: a) 2
6 What is the output of the below program? 1
def func(a, b=5, c=10):
print('a is', a, 'and b is', b, 'and c is', c)
func(3, 7)
func(25, c = 24)
func(c = 50, a = 100)
Ans: b) count()
20 Assertion(A):Python uses immutable types for call by value mechanism
Reason (R): in the call by value mechanism, the called function makes a separate copy of passed
values and then works with them.
a) Both A and R are wrong
b)A is wrong, but R is right
c)A is right, but R is wrong
d)Both A and B are Right
Ans: d)Both A and B are Right
21 Assertion (A): Python automatically flushes the file buffers before closing a file with close ()
function.
Reason (R): when you open an existing file for writing, it adds the content at the end of the file.
a) Both A and R are wrong
b)A is wrong, but R is right
c)A is right, but R is wrong
d)Both A and B are Right
Ans: c)A is right, but R is wrong
SECTION-B
22 Write the output given by following Python code. 2
x=1
def fun1():
x=3
x=x+1
print(x)
def fun2():
global x
x=x+2
print(x)
fun1()
fun2()
OR
What do you mean by default parameters? Explain with the help of suitable example.
Ans: 4
3
OR
Definition-1
Suitable example-1
23 (i) Write the SQL statement to add a field Country_Code(of type Integer) to the table Countries 1+1
withthe following fields.
Country_id, Country_name, Continent, Region_id
(ii) Which of the following is not a DML command?
DELETE FROM, DROP TABLE, CREATE TABLE, INSERT INTO
Ans: (i) for writing of alter table query-1
(ii) DROP TABLE-1
24 What are the possible outcome(s) executed from the following code? Also specify the maximum 2
and minimum values that can be assigned to variable N.
import random
SIDES=["EAST","WEST","NORTH","SOUTH"]
N=random.randint(1,3)
OUT=""
for I in range (N,1, –1):
OUT=OUT+SIDES[I]
print (OUT)
(i) SOUTHNORTH
(ii) SOUTHNORTHWEST
(iii) SOUTH
(iv) EASTWESTNORTH
Ans: (ii) SOUTHNORTHWEST -1 mark
Maximum value of variable N is 3- ½ mark
Minimum value of variable N is 1- ½ mark
25 Write two points of difference between Bus Topology and Tree Topology. 2
OR
Write two points of difference between Packet Switching and Circuit Switching techniques?
Ans:
BUS TOPOLOGY STAR TOPOLOGY
Bus topology is a topology where each device is connected Star topology is a topology in which all
to a single cable which is known as the backbone. devices are connected to a central hub
In a Bus topology, the failure of the network cable will In star topology, if the central hub fails then
cause the whole network to fail. the whole network fails.
In a bus topology, there is a linear arrangement of nodes in In star topology, there is a non-linear
a network. arrangement of nodes in a network.
OR
DOMAIN OF
CIRCUIT SWITCHING PACKET SWITCHING
COMPARISON
Finds maximum usage in voice-over It has wide utility in the field of data
Utility
or telephonic communication. transmission over networks.
26 2
Write the output of the queries (a) to (d) based on the table SCHOOLADMINgiven below:
a) SELECT max (DOB) FROM SCHOOLADMIN;
b) SELECT Name FROM SCHOOLADMIN WHERE STREAM<>"Business Admin" AND
SECTION IS NULL;
c) SELECT count (NAME) FROM SCHOOLADMIN WHERE SECTION IS NOT NULL;
d) SELECT count (NAME) FROM SCHOOLADMIN WHERE SECTION IS NOT NULL AND
STREAM="FINE ARTS";
Ans: a)Max(DOB)
2005-05-12
b)empty set
c)count(name)
5
d)count(name)
2
27 Rewrite the following Python program after removing all the syntactical errors (if any), 2
underlining each correction:
def checkval:
x = input(“Enter a number”)
if x % 2 = 0:
print x,”is even”
else if x<0:
print x,”should be positive”
else;
print x,”is odd”
Ans: def checkval:
x = int(input(“Enter a number”))
if x % 2 == 0:
print (x,”is even” )
elif x<0:
print( x,”should be positive”)
else:
print( x,”is odd”)
28 (a) What is the output produced by the following code – 1
d1={“b”:[6,7,8],”a”:(1,2,3)}
print(d1.values())
a) { (1,2,3) , [6,7,8] }
b) [[6,7,8],(1,2,3)]
c)[6,7,8,1,2,3]
d) (“b”, “a”)
(b) What is the output of given program code: list1 = range(100,110) 1
print( list1.index(105))
(a) 4 (b) 5 (c) 6 (d) Error
Ans: (b)[[6,7,8],(1,2,3)]
(b) 5
SECTION-C
29 (a)Write a function in python to count the number of lines in “POEM.txt” begins from Upper case 3
character.
OR
Write a function in python to read lines from file “POEM.txt” and count how many times the word
“INDIA” exists in file.
Ans: for function header- ½ mark
for body of the function(including opening of the file,logic) -1 ½ mark
closing of the file- ½ mark
30 Write a function in Python PUSH(Num), where Num is a list of integer numbers. From this list 3
push all positive even numbers into a stack implemented by using a list. Display the stack if it has
at least one element, otherwise display appropriate error message.
OR
Write a function in Python POP(cities), where cities is a stack implemented by a list of city names
for eg. cities=[‘Delhi’, ’Jaipur’, ‘Mumbai’, ‘Nagpur’]. The function returns the value deleted from
the stack.
Ans: For writing of the push function with all syntax and correct logic-3 marks
31 (a)Sonal needs to display name of teachers, who have “0” as the third character in their name. She 1
wrote the following query.
SELECT NAME FROM TEACHER WHERE NAME = “$$0?”;
But the query is’nt producing the result. Identify the problem.
(b)Write output for (i) & (iv) based on table COMPANY and CUSTOMER.
ii. 50000,70000
iii.11
iv.
32 Write a function EVEN_LIST(L), where L is the list of elements passed as argument to the 3
function. The function returns another list named ‘evenList’ that stores the indices of all even
numbers of L.
For example:
If L contains [12,4,3,11,13,56]
The evenList will have - [0,1,5]
Ans: def EVEN_LIST(L):
evenList=[]
for i in L:
if i%2==0:
evenList.append(i)
return(evenList)
SECTION-D
33 Write a python program to create a csv file dvd.csv and write 10 records in it with the following 5
details: Dvdid, dvd name, qty, price.
Display those dvd details whose dvd price is more than 25.
Ans: import csv
f=open("pl.csv","w")
cw=csv.writer(f)
ch="Y"
while ch=="Y":
l=[]
pi=int(input("enter dvd id "))
pnm=input("enter dvd name ")
sp=int(input("enter qty "))
p=int(input("enter price(in rupees) "))
l.append(pi)
l.append(pnm)
l.append(sp)
l.append(p)
cw.writerow(l)
ch=input("do you want to enter more rec(Y/N): ").upper()
if ch=="Y":
continue
else:
break
f.close()
f=open("pl.csv","r+")
cw=list(csv.reader(f))
for i in cw:
if l[3]>25:
print(i)
f.close()
34 Consider the tables below to write SQL Queries for the following:
i.To display TEACHERNAME, PERIODS of all teachers whose periods are more than 25.
ii.To display all the information from the table SCHOOL in descending order of experience.
iii. To display DESIGNATION without duplicate entries from the table ADMIN.
iv. To display TEACHERNAME, CODE and corresponding DESIGNATION from tables
SCHOOL and ADMIN of Male teachers.
Ans:
SECTION-E
35 Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at Chennai
with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN, ENGINEERING,
BUSINESS and MEDIA.
You as a network expert have to suggest the best network related solutions for their problems raised in (i) to
(v), keeping in mind the distances between the buildings and other given parameters.
(i) Suggest the most appropriate location of the server inside the CHENNAI campus (out of the 4
buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
(ii) Suggest and draw the cable layout to efficiently connect various buildings within the
CHENNAI campus for connecting the computers.
(iii) Which hardware device will you suggest to be procured by the company to be installed to
protect and control the internet uses within the campus ?
(iv) Which of the following will you suggest to establish the online face-to-face communication
between the people in the Admin Office of CHENNAI campus and DELHI Head Office ?
(a) Cable TV
(b) Email
(c) Video Conferencing
(d) Text Chat
(v) Name protocols used to send and receive emails between CHENNAI and DELHI office?
(i)admin; it contains the max number of systems. to reduce traffic
(ii)
(iii)firewall
(iv) (c) Video Conferencing
(v) POP and SMTP
36 A binary file “STOCK.DAT” has structure [ITEMID, ITEMNAME, QUANTITY, PRICE]. 5
(i) Write a user defined function MakeFile( )to input data for a record and add to Book.dat.
(ii) Write a function GetPrice(ITEMID) in Python which accepts the ITEMID as parameter and
return PRICE of the Item stored in Binary file STOCK.DAT.
OR
A binary file “EMPLOYEE.DAT” has structure (EMPID, EMPNAME, SALARY). Write a
function CountRec( )in Python that would read contents of the file “EMPLOYEE.DAT” and
display the details of those Employees whose Salary is above 20000. Also display number of
employees having Salary more than 20000.
Ans: For function MakeFile()-2 marks
For function GetPrice()-3 marks
37 (a)Write the outputs of the SQL queries (i) to (ii) based on relations EMP and DESIG given
below:
Table: EMP
E_ID Name Gender Age DOJ Designation
1 Om Prakash M 35 10/11/2009 Manager
2 Jai Kishan M 32 12/05/2013 Accountant
3 Shreya Sharma F 30 05/02/2015 Clerk
4 Rakesh Minhas M 40 15/05/2007 Manager
5 Himani Singh F 33 19/09/2010 Clerk
Table: DESIG
Salary E_ID DEPT_ID
45000 1 D101
35000 2 D102
45000 4 D101
(i) SELECT Designation, count(*) FROM EMP GROUP BY Designation;
(ii) SELECTEMP.Name,EMP.Designation,DESIG.Salary FROM EMP,DESIG WHERE
EMP.E_ID = DESIG.E_ID AND EMP.Age>35;
(b)
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is root@123
• The table exists in a MYSQL database named management.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those employees whose salary are greater
than 53500.
Statement 3- to read the complete result of the query (records whose salary are greater than 53500)
into the object named data, from the table employee in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",password="root@123",
database="management")
mycursor=_______________ #Statement 1
print("Employees with salary greater than 53500 are : ")
_________________________ #Statement2
data=__________________ #Statement 3
for i in data:
print(i)
print()
Ans:
(a) For each output of the query 1 mark
(b)
Statement 1: con1.cursor()
Statement 2: mycursor.execute("select * from student where Marks>75")
Statement 3: mycursor.fetchall()