Cssc-2022-Class Xii-Csc-Ms
Cssc-2022-Class Xii-Csc-Ms
COMMON EXAMINATION
CLASS – XII
COMPUTER SCIENCE (083)
ANSWER KEY
Time: 3 hours Maximum Marks:70
General Instructions:
❖ This Question paper contains 24 printed pages.
❖ This Question paper contains 35 Questions.
❖ Write down the question number before attempting.
❖ An additional reading time of 15 minutes.
General Instruction to answer this Question paper:
1. This Question paper contains Five Sections, Section A to E.
2. All Question are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 very Short Answer Type Questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in
Q34 against part (iii) only.
8. All Programming questions are to be answered using python language only.
SECTION A
1. Which of the following is an unordered collection of elements in python? 1
(a)List (b) Tuple (c) Dictionary (d) String
(c) Dictionary
2. Identify the invalid variable name from the following. 1
Adhar@Number, none, 70outofseventy, mutable
Adhar@Number, 70outofseventy
3. Consider the coding given below and fill in the blanks: 1
Dict_d={„BookName‟:‟Python‟,‟Author‟:”Arundhati Roy”}
Dict_d.pop() # Statement 1
List_L=[“java”,”SQL”,”Python”]
List_L.pop() # Statement 2
(i) In the above snippet both statement 1 and 2 deletes the last element
from the object Dict_d and List_L________(True/False).
(ii) Statement_______(1/2) alone deletes the last element in its object.
(i) False
(ii) Statement 2
Page 1 of 24
4. Evaluate the following expression. 1
False and bool(15/5*10/2+1)
False
5. Write the output for the following python snippet. 1
LST=[1,2,3,4,5,6]
for i in range(6):
LST[i-1]=LST[i]
print(LST)
[2, 3, 4, 5, 1, 1]
6. Out of the following file mode which opens the file and delete all its 1
contents and place the file pointer at the beginning of the file.
(a) a (b) w (c) r (d) a+
(b) w
Page 2 of 24
d=dict() # 1/ 2 mark
n=int(input("enter number of terms")) 1/2 mark
for i in range(n):
a=input("enter a character")
d[i]=a
10. In MYSQL _____ clause applies the condition on every ROW and ______ 1
clause applies the condition on every GROUP.
WHERE,HAVING
11. Complete the following snippet to open the file and create a writer object 1
for a csv file “emp.csv” with delimiter as pipe symbol „|‟ to add 5 more
records into the file using the list named “e_rec”.
emp_file=___________
csv_writer=csv.writer( ____________ )
emp_file=open(“emp.csv”,”ab”)
csv_writer=csv.writer( e_rec,emp_file )
15. Which command is used to display the structure of the table? Write the 1
syntax of the command.
DESC <table name>
16. Which function of mysql.connector library lets you check if the connection 1
to the database is established or not?
(a) connectionobject.is_connected()
(b) mysql.connector,connect()
(c) mysql.connector()
(d) mysql.connector
(a) connectionobject.is_connected()
Page 3 of 24
Q17 and Q18 are ASSERTION and REASONING based questions. Mark the correct
choice as
(a) Both A and B 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) : When we open the file in write mode the content of the file will be 1
erased if the file already exist.
Reasoning(R): Open function will create a file if does not exist, when we create
the file both in append mode and write mode.
(a) Both A and B are true and R is the correct explanation for A.
18. Assertion(A): Keyword argument were the named arguments with assigned 1
values being passed in the function call.
Reasoning (R): Default arguments cannot be skipped while calling the function
while keyword arguments are in function call statement.
(c ) A is True but R is False
SECTION B
19. Mr. Gupta want to print the city he wants to visit and the distance to reach 2
that place from his native. But his coding is not showing the correct output
debug the code to get the correct output and state what type of argument
he tried to implement in his coding.
def Travel (c,d)
print(“Destination city is “,distance)
print(“Distance from native is “,city)
Travel(distance=”18 KM”,city=”Tiruchi”)
def Travel(city,distance): # in any order variable name can be used 1
mark
print("Destination city is ", city)
print("Distance from native is ", distance)
Travel(distance="18 KM",city="Tiruchi") # ½ mark
Keyword argument or Named argument # ½ mark
20. What is meant by domain name? Give an example 2
OR
List any two difference between bridge and router
proper definition for domain (1/2 mark) and example for domain (1/2
mark)
Page 4 of 24
Or
Each difference carries 1 mark
21. Write the output for the following python code: 2
def Change_text(Text):
T=""
for K in range(len(Text)):
if Text[K].isupper():
T=T+Text[K].lower();
elif K%2==0:
T=T+Text[K].upper()
else:
T=T+T[K-1]
print(T)
Text="Good Go Head"
Change_text(Text)
ggOO gOOhhAA
22. What is the difference between Equi join and Natural join. Give an 2
Example
Page 5 of 24
24. def Quo_Mod (L1): 2
L1.extend([33,52])
for i in range(len(L1)):
if L1[i]%2==0:
L1[i]=L1[i] /5
else:
L1[i]=L1[i]%10
L=[100,215,310]
print(L)
Quo_Mod (L)
print(L)
OR
What possible outputs are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the
maximum value that can be assigned to each of the variables L and U.
import random
Arr=[10,30,40,50,70,90,100]
L=random.randrange(1,3)
U=random.randrange(3,6)
for i in range(L,U+1):
print(Arr[i],"@",end="")
Page 6 of 24
25. What is the difference between column constraint and table constraint? 2
Give an example.
OR
What is the difference between LIKE and IN operator in MYSQL. Give an
example.
Difference between column constraint and table constraint -1 Mark
Example carries 1 Mark
OR
LIKE : used to compare pattern with „_‟ , „%‟ 1/2 Mark
IN : used to compare list of values 1/2 Mark
Each Example carries 1/2 Mark
SECTION C
26. (a) Consider the following tables FACULTY and STUDENT. Write the 3
output for the MYSQL statement given below and state what type of
join is implemented.
SELECT * FROM FACULTY,STUDENT
FACULTY STUDENT
Faculty_Id Name Stu_id Stu_Name
F100 Govardhan 12101 Anitha
F101 Janet 12102 Vishnu
F102 Rithu
(b) Write the output for the queries (i) to (iv) based on the table.
SPOTRS
S_ID SNAME FEES START_DT No_of_Players
S1 Foot Ball 5000 2015-01-10 25
S2 Basket Ball 4000 2016-10-10 30
S3 Volley Ball 5000 2017-02-02 25
S4 Kho-Kho 5500 2017-03-20 40
S5 Basket Ball 6000 2016-02-15 50
Page 7 of 24
(a) SELECT * FROM FACULTY,STUDENT
Output 1/ 2 Mark
(i) 1 /2 Mark
(ii) 1 /2 Mark
Page 8 of 24
(iii) 1 /2 Mark
(iv) 1 /2 Mark
OR
Write a function V_COUNT() to read each line from the text file and count
number of lines begins and ends with any vowel.
Example:
Eshwar returned from office and had a cup of tea.
Page 9 of 24
Veena and Vinu were good friends.
Anusha lost her cycle.
Arise! Awake! Shine.
The function must give the output as:
Number of Lines begins and ends with a vowel is 3
ANS:
def COUNT_CHAR():
f=open("math.txt","r")
txt=f.read()
a=s=m=d=0
for i in txt:
if i =='+':
a+=1
elif i=='-':
s+=1
elif i=='*':
m+=1
elif i=='/':
d+=1
print("Number of '+' sign is",a)
print("Number of '-' sign is",s)
print("Number of '*' sign is",m)
print("Number of '/' sign is",d)
f.close()
COUNT_CHAR()
½ mark for opening and closing
½ mark for reading the content from the file
½ mark for traversing the character
½ mark for comparing the operators
½ mark for counting the operators
½ mark for printing the output
OR
def V_COUNT():
Page 10 of 24
f=open("string_begin.txt","r")
L=" "
c=0
for i in f:
print(len(i))
if i[0] in"aeiouAEIOU" and i[-2] in "aeiouAEIOU":
c=c+1
print("Number of Lines begins and ends with a vowel is",c)
V_COUNT()
½ mark for opening and closing the file.
½ mark for reading the line
½ mark for traversing the file
½ mark for comparing
½ mark for counting
½ mark for printing
28. (a) Write the SQL Queries for (i) to (iii) based on the table 3
EMPLOYEE and DEPARTMENT.
EMPLOYEE
EMP_ID Name DEPT JOIN_DT SALARY
E1 Vanitha 101 2015-01-01 50000
E2 Karthika 102 2015-02-01 75000
E3 Prathiba 103 2014-01-05 85000
E4 Mihika 101 2016-06-10 100000
E5 Mridula 102 2014-10-15 95000
DEPARTMENT
DEPT_ID D_NAME
101 Production
102 Sales
103 Marketing
Page 12 of 24
½ mark for adding the element into the list
½ mark for returning the list
½ mark for printing the values of the list
30. Mohammed has created a dictionary containing names and marks of 3
computer science as key,value pairs of 5 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 (CS marks) are more than or equal to 90 .
● Pop and display the content of the stack,if the stack is empty display the
message as “UNDER FLOW”.
For example: If the sample content of the dictionary is as follows:
CS={"Raju":80, "Balu":91, "Vishwa":95, "Moni":80, “Govind":90}
The output from the program should be:
Balu Vishwa Govind
The pop operation must display
Govind
vishwa
Balu
UNDER FLOW
OR
Dev Anand have a list of 10 numbers. You need to help him create a
program with separate user defined functions to perform the following
operations based on this list.
● Traverse the content of the list and push the numbers divisible by 5 into
the stack.
● Pop and display the content of the stack, if the stack is empty display the
message” STACK EMPTY”
For Example:
If the sample Content of the list is as follows:
N=[2,5,10,13,20,23,45,56,60,78]
After the push operation the list must contain
5,10,20,45,60
And pop operation must display the output as
60
45
20
10
5
Page 13 of 24
STACK EMPTY
ANS
CS={"Raju":80, "Balu":91, "Vishwa":95, "Moni":80,"Govind":90}
names=[]
def push():
for i in CS: #1/ 2 MARK
if CS[i]>=90: #1/ 2 MARK
names.append(i) #1/ 2 MARK
print(names)
def pop():
while len(names)!=0: #1/ 2 MARK
print(names.pop()) #1/ 2 MARK
else:
print("UNDER FLOW") #1/ 2 MARK
push()
pop()
OR
N=[2,5,10,13,20,23,45,56,60,78]
stack=[]
def push():
for i in N: #1/ 2 MARK
if i%5==0: #1/ 2 MARK
stack.append(i) #1/ 2 MARK
print(stack)
def pop():
while len(stack)!=0: #1/ 2 MARK
print(stack.pop()) #1/ 2 MARK
else:
print("STACK EMPTY") #1/ 2 MARK
push()
pop()
Page 14 of 24
31. A professional consultancy company is planning to set up new offices in 5
India with its hub at Chennai. As a network adviser, you have to
understand their requirements and suggest to them the best available
solutions.
Block Computers
Human Resources 125
Conference 25
Finance 60
(a) What will be the most appropriate block where the organization should
plan to install their server?
(b) Draw a block-to-block cable layout to connect all the buildings in the
most appropriate manner for efficient communication.
(c) What will be the best possible connectivity out of the following to
connect the new set-up of offices in Chennai with its London base office?
(i) Infrared (ii) Satellite Link (iii) Ethernet Cable
(d) Which of the following devices will you suggest to connect each
computer in each of the above buildings?
(i) Gateway (ii) Switch (iii) Modem
Page 15 of 24
a) Human Resources (1 Mark)
b) any proper layout connecting all the three blocks. (1 Mark)
L1=[10,15,20]
LST_ARG(L1)
print("L1->",L1)
OUTPUT:
L2-> [10, 15, 20]
L3-> [0, 0, 0, 0]
L1-> [100, 225, 400, 51]
L2-> [100, 225, 400, 51]
Page 16 of 24
L3-> [0, 0, 0, 0]
L1-> [100, 225, 400, 51]
First three line carries 1 Mark.
Last three line carries 1 Mark.
(b) The Python program establishes connection between python and mysql,
and display the students details where the marks were between 80 to 90.
Write the missing statement to complete the code.
Statement 1 – to check whether connection is not established.
Statement 2 – to create cursor object.
Statement 3 – to retrieve all the data from the cursor object.
import mysql.connector
conn=mysql.connector.connect(host="localhost",user="root",passwd="123
45",database="student")
if______________ # Statement 1
print("Error connecting to MYSQL DATABASE")
________________ # Statement 2
c.execute("select * from student where marks>80 and marks<90")
_____________ # Statement 3
count=c.rowcount
print("total no of rows:",count)
for row in r:
print(row)
Ans
Statement 1 > if conn.is_connected()==False:
Statement 2 > c=conn.cursor()
Statement 3 > r=c.fetchall()
OR
(a) Write output for the following code given below:
def OUTER(Y,ch):
global X,NUM
Y=Y+X
X=X+Y
print(X,"@",Y)
if ch==1:
Page 17 of 24
X=inner_1(X,Y)
print(X,"@",Y)
elif ch==2:
NUM=inner_2(X,Y)
def inner_1(a,b):
X=a+b
b=b+a
print(a,"@",b)
return a
def inner_2(a,b):
X=100
X=a+b
a=a+b
b=a-b
print(a,"@",b)
return b
X=100
NUM=1
OUTER(NUM,1)
OUTER(NUM,2)
print(NUM,"@",X)
OUTPUT:
201 @ 101
201 @ 302
201 @ 101
403 @ 202
605 @ 403
403 @ 403
First 3 lines carries 1 Mark
Last 3 lines carries 1 Mark
(b) Consider the following Python code is written to access the details of
employee, whose employee number is given:
Complete the missing statements:
Statement 1 – To create a cursor object to execute the query.
Statement 2 – To execute the query stored in the variable change.
Statement 3 – To make the changes in the database physically.
Page 18 of 24
def Search():
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="system",database="DB")
_______________ # Statement 1
change="update employee set salary=salary+5000 where empno=
1011"
_______________ # Statement 2
______________ # Statement 3
results = mycursor.fetchall()
print(results)
Ans:
Statement 1 > mycursor=mydb.cursor()
Statement 2 > mycursor.execute(change)
Statement 3 > mydb.commit()
33. What is the use of seek() function ? Write a python program that defines 5
and calls the following user defined functions.
Add_book() – To read the details of the books from the user and write into
the csv file named “book.csv”. The details of the books stored in a list are
book_no,name,author.
Search_book() - To read author name from the user and display the books
written by that author.
OR
How to open the file using with statement? Write a python program that
defines and calls the user defined functions given below.
Add_rating() – To read product name and rating from the user and store the
same into the csv file “product.csv”
Display() – To read the file “product.csv” and display the products where
the rating is above 10
In Python, seek() function is used to change the position of the File Handle
to a given specific position.
Syntax: fi.seek(offset, from_where), where fi is the file pointerOffset: This
is used for defining the number of positions to move forward.
from_where: This is used for defining the point of reference. It can take
0: beginning of the file. 1: current position of the file. 2: end of the file.
1 /2 Mark for explanation 1 /2 mark syntax and example.
Page 19 of 24
import csv # 1/2 Mark
def Add_book():
f=open("book.csv","a",newline='') # 1/2 Mark for opening and closing
the file
ans='y'
book=[]
w_obj=csv.writer(f) # 1 /2 Mark
while ans=='y':
book_no=int(input("Enter book no"))
name=input("Enter book name")
author=input("enter author name")
book=[book_no,name,author]
w_obj.writerow(book) # 1 /2 Mark
ans=input("do yu want to continue")
f.close()
def search_book():
f=open("book.csv",'r',newline='')
au_name=input("enter author name")
found=False
book_lst=csv.reader(f) # 1 /2 Mark
for i in book_lst: # 1 /2 Mark
if i[2]==au_name: # 1 /2 Mark
found=True
print(i)
if found==False:
print("author not found")
f.close()
search_book()
OR
In Python, we can also open a file using with statement.
The syntax of with statement is:
Page 20 of 24
with open (file_name, access_mode) as file_object:
with open(“myfile.txt”,”r+”) as myObject:
content = myObject.read()
Here, we don‟t have to close the file explicitly using close() statement.
Python will automatically close the file.
Syntax Example– 1 /2 Mark,Explanation 1 /2 Mark
display()
Page 21 of 24
SECTION E
34. Naveen created a table SALES_DONE to maintain the sales made by his 1+1+2
sales department. The table consists of 10 employees records. To record
every months sales he is adding a new column with first three characters of
that month.
ANS
Page 22 of 24
(iii)
(a) mysql> INSERT INTO SALES_DONE VALUES(106,"Venkatesh
Gour",256489,200,300);
(b) mysql> UPDATE SALES_DONE SET NAME='Sri Nikethan' WHERE
EMP_NO=104;
OR
(iii)
(a) ALTER TABLE SALES_DONE ADD(TOTAL_SALES INTEGER
NOT NULL);
(b) UPDATE SALES_DONE SET TOTAL_SALES=JAN+FEB;
35. Mrs.Renu wrote a python program to update the salary of the employee by 4
reading the employee number. She got some errors while executing the
program so she deleted those lines. As a python programmer guide her to
fill the missing statements.
_____________ # Statement 1
def modify():
e=[ ]
____________ # Statement 2
found=False
T_eno=int(input("enter employee no"))
try:
while True:
____________ # Statement 3
e=pickle.load(f)
if e[0] == T_eno:
e[2]=float(input("enter new salary"))
f.seek(pos)
__________ # Statement 4
found=True
except:
f.close()
if found==True:
print("employee record found and updated")
else:
print("employee record not found and updating not possible")
(i) Write the statement to import the needed module.
(ii) Write the statement to open the file named “emp.bin” as per the
need of the code.
Page 23 of 24
(iii) Write the statement to store the position of the file pointer.
(iv) Complete the blank with the statement to write the object “e”
into the file.
“End of Paper”
Page 24 of 24