Coimbatore Sahodaya Set A Key

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

A

GRADE: XII PRE – BOARD EXAMINATION (DEC–2022) MARKS:70


SUBJECT: COMPUTER SCIENCE ANSWER KEY TIME: 3 HRS
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 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 Q35
against Part-C only
8. All programming questions are to be answered using Python Language only.

S.NO SECTION-A MARKS


1 Find the invalid identifier from the following
(a) name (b) class (c) section (d) break 1
Ans. (d) break
2 State true or false:
(i) -88.0 is the output of the print(3-10**2+99/11) 1
(ii) Range( ) is also a module function.
Ans.(i) True (ii) False
3 What is the output of the following code?
a=[1,2,3,4,5]
for i in range(1,5):
a[i-1]=a[i] 1
for i in range(0,5):
print(a[i],end=" ")
(a) 5 5 1 2 3 (b) 5 1 2 3 4 (c) 2 3 4 5 1 (d) 2 3 4 5 5
Ans. (d) 2 3 4 5 5
4 Given the Python declaration s1=”Hello”. Which of the following
statements will give an error? 1
(a) print(s1[4]) (b) s2=s1 (c) s1=s1[4] (d) s1[4]=”Y”
Ans. (d) s1[4]=”Y”
5 Identify the output of the following Python statement:
s=”Good Morning”
print(s.capitalise( ),s.title( ), end=”!”) 1
(a) GOOD MORNING!Good Morning
(b) Good Morning! Good Morning
(c) Good morning! Good Morning!
(d) Good morning Good Morning!
Ans. (d) Good morning Good Morning!
6 What is the output of the functions shown below? 1
min(max(False,-3,-4),2,7)
(a) -3 (b) -4 (c) True (d) False
Ans. (d) False
7 Suppose the context of “Rhymes.txt” is
Hickory Dickory Dock 1
The mouse went up the clock
What will be the output of the following Python code?
f=open(“Rhymes.txt”)
l=f.readlines()
x=[“the”,”ock”]
for i in l:
for w in i.split():
if w in x:
print(w,end=”*”)
(a) the* (b) the*the* (c) Dock*the*clock* (d) error
Ans. (b) the*the*
8 Which of the following statement is not correct?
(a) We can write content into a text file opened using ‘w’ mode
(b) We can write content into a text file opened using ‘w+’ mode
(c) We can write content into a text file opened using ‘r’ mode
(d) We can write content into a text file opened using ‘r+’ mode 1
Ans. (c) We can write content into a text file opened using ‘r’ mode
9 ___________ is a protocol that allows to send/upload email message from 1
local computer to an email server.
Ans. SMTP
10 What will the following code do?
dict={“Phy”:94,”Che”:70,”Bio”:82,”Eng”:95}
dict.update({“Che”:72,”Bio”:80}) 1
(a) It will create new dictionary as dict={“Che”:72,”Bio”:80} and old dict
will be deleted
(b) It will throw an error as dictionary cannot be updated
(c) It will simply update the dictionary as
dict={“Phy”:94,”Che”:72,”Bio”:80, “Eng”:95}
(d) It will not throw any error but it will not do any changes in dict
Ans. (c) It will simply update the dictionary as
dict={“Phy”:94,”Che”:72,”Bio”:80, “Eng”:95}
11 Command to remove the row(s) from table student is 1
(a) drop table student; (b) drop from student;
(c) remove from student; (d) delete from student;
Ans. (d) delete from student;
12 Which SQL command is used to add a new attribute in a table? 1
13 The following SQL command is which type of join: 1
SELECT customer, cust_id,order,cust_id, name, order_id FROM
customer, order;
(a) Equi-join (b) Natural join (c) Outer join (d) Cartesian product
Ans. (d) Cartesian product
14 In order to open a connection with MySQL database from within Python 1
using mysql.connector package, ________ function is used.
(a) open( ) (b) database( ) (c) connect( ) (d) connected( )
Ans. (c) connect()
15 The aggregate functions can only be used in the select list or _______ 1
clause of a select query.
Ans. Having
16 __________ counts only those rows that contain a value; it ignores all null 1
values in the field.
Ans. Count<Col_Name>
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): The readline( ) method reads one complete line from a text 1
file.
Reason(R): The readline( ) method reads one line at a time ending with a
newline(\n). It can also be used to read a specified number (n) of bytes of
data from a file but maximum up to the newline character(\n)
(a) Both A and R are true and R is the correct explanation for A
18 Assertion(A): Keyword arguments are related to function calls. 1
Reason(R): When you use keyword arguments in a function call, the caller
identifies the arguments by the values passed.
(b) Both A and R are true and R is not the correct explanation for A
S.NO SECTION-B MARKS
19 Rewrite the following Python program after removing all the syntactical 2
errors (if any), underlining each correction:
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. x=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”

20 Why do we need to network our systems?


(OR) 2
How is Coaxial cable different from Optical Fibre?
Ans. (i) Resource sharing (ii) Reliability (iii) Cost factor (iv)
communication medium
(OR)
Coaxial cables have solid wire core surrounded by one or more foil or wire
shield whereas optical fibres consist of thin strands of glass or glass like
materials. CC can transmit electrical signals whereas OPf transmit light
signals
21 (a) Find the output generated by the following code: 1
a=5
b=10
a+=a+b
b*=a+b
print(a,b)
(b) Answer the following questions from the following code: 1
num_list=[“One”,”Two”,”Three”,”Four”]
for c in num_list:
print(c)
(i) What will be the output of the above code?
(ii) How many times the loop executed?
Ans. (i) One
Two
Three
Four
(ii) The loop executed 4 times
22 What is the similarity and difference between UNIQUE and PRIMARY 2
KEY constraints?
Ans. S: Both ensure that the attribute they are applied upon, contain the
unique values for each row/tuple in those attributes
D: Primary key can be applied only once in a table, to a single attribute,
Unique key can be applied to any number of columns in a table.
Primary does not contain any Null values whereas unique key can contain
Null values
23 (a) What is the difference between HTTP and FTP? 2
(b) Expand the following: SLIP, PPP
Ans. (a) HTTP: used to transfer files from a web server onto a browser in
order to vies a web page that is on the internet; used to define the format
and transfer the web page
FTP: used to upload file from a workstation to a FTP server or download
files from a FTP server to a workstation; used to transfer file from one
system to another
(b) SLIP: Serial Line Internet Protocol
PPP: Point to Point Protocol
24 Determine the output of the following code fragments:
def determine(s):
d={“UPPER”:0, ”LOWER”:0}
for c in s:
if c.isupper( ):
d[“UPPER”]+=1 2
elif c.islower( ):
d[“LOWER”]+=1
else:
pass
print(“Original String:”,s)
print(“Upper case count:”, d[“UPPER”])
print(“Lower case count:”, d[“LOWER”])
determine(“These are HAPPY Times”)
Ans. Original String: These are HAPPY Times
Upper case count: 7
Lower case count: 11
(OR)
Find and write the output of the following Python code:
def fun(s):
k=len(s)
m=” “
for i in range(0,k):
if (s[i].isupper( )):
m=m+s[i].lower( )
elif s[i].isalpha( ):
m=m+s[i].upper( )
else:
m=m+’bb’
print(m)
fun(‘school2@com’)
Ans. SCHOOLbbbbCOM
25 Write the full forms of DDL and DML. Write any two commands of DML 2
in SQL.
Ans. DDL-Data Definition Language, DML-Data Manipulation Language
DML; INSERT, UPDATE, DELETE
(OR)
What is the use of GROUP BY clause? Give example.
Ans. Used to group records of a table on the basis of a common value of a
column and get a summarized result for the group as per a defined
function,e.g., if in a class students belong to different school houses, then
we can count the number of students in each house using a GROUP BY
command such as:
SELECT count(house) FROM student
GROUP BY house;
S.NO SECTION-C MARKS
26 Consider the following tables: CONSIGNOR and CONSIGNEE 3
Table: CONSIGNOR
CnorID CnorName CnorAddress City
ND01 R.Singhal 24, ABC Enclave New Delhi
ND02 Amit Kumar 123, Palm Avenue New Delhi
MU15 R Kohli 5/A, South Street Mumbai
MU50 S Kaur 27-K, Westend Mumbai

Table: CONSIGNEE
CneeID CnorID CneeName CneeAddress CneeCity
MU05 ND01 Rahul Kishore 5, Park Avenue Mumbai
ND08 ND02 P Dhinga 16/J, Moore Enclave New Delhi
KO19 MU15 A P Roy 2A, Central Avenue Kolkata
MU32 ND02 S Mittal P 245, AB Colony Mumbai
ND48 MU50 B P Jain 13, Block D, A Vihar New Delhi
Give output for the following SQL queries:
(i) SELECT A.CnorName, B.CneeName
FROM Consignor A, Consignee B
WHERE A.CnorID=B.CnorID AND B.CneeCity=’Mumbai’;
(ii) SELECT CneeName, CneeAddress
FROM Consignee
WHERE CneeCity NOT IN(‘Mumbai’, ‘Kolkata’);
(iii) SELECT DISTINCT CneeCity FROM Consignee;
Ans. (i) R Singhal Rahul Kishore
Amit Kumar S Mittal
(ii) P Dhingra 16/j, Moore Enclave
BP Jain 13, Block D, A Vihar
(iii) Mumbai
New Delhi
Kolkata
27 Write a function Show_words( ) in python to read the content of a text file 3
‘NOTES.TXT” and display the entire content in capital letters. Example if
the file contains:
“This is a test file”
Then the function should display the output as:
THIS IS A TEST FILE
Ans. def Show_words( ):
file=open(‘Notes.txt’,’r’)
Lines=file.readlines( )
for L in Lines:
print(L.upper())
file.close( )
(OR)
Write a function countmy( ) in python to read the text file “DATA.TXT”
and count the number of times “my” occurs in the file.
For example if the file “DATA.TXT” contains:
“This is my website. I have displayed my preferences in the CHOICE
section”
The countmy( ) function should display the output as : “my occurs 2 times”
Ans. def countmy( ):
f=open(“data.txt”,”r”)
count=0
x=f.read( )
word=x.split( )
for i in word:
if i==”my”:
count=count +1
print(“my occurs”, count, “times”)
f.close( )
countmy( )
28 Consider the following tables WORKER and PAYLEVEL and answer the 3
following parts of this question:
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhe Supervisor P001 13-09- 23-08-
Shyam 2004 1981
12 Chander Operator P003 22-02- 12-07-
Nath 2010 1987
13 Fizza Operator P003 14-06- 14-10-
2009 1983
15 Ameen Mechanic P002 19-12- 13-03-
Ahmed 2005 1983
18 Sanya Clerk P002 19-12- 09-06-
2005 1983
Table: PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
Give the output for the following SQL queries:
(i) SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY
PLEVEL;
(ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W.PLEVEL=P.PLEVEL AND W.CODE<13;
Ans. (i) 1 P001 (ii) 12-Jul-1987 13-Sep-2004
2 P003
3 P002
(iii) Name Pay
Radhe shyam 26000
Chander Nath 12000
29 Write a function stats( ) that accepts a filename and reports the file’s longest 3
line.
Ans. def stats(filename):
longest=” “
for line in file(filename):
if len(line)> len(longest)
longest=line
print(“Longest line’s length=” , len(longest))
print (longest)
30 Write Addnew(Book) and Remove(Book) functions in python to add a new 3
book and remove a book from a List of books, considering them to act as
PUSH and POP operations of the data structure Stack.
Ans. Book=[ ]
def Addnew(s):
name=input(“Enter book name:”)
Book.append(name)
def Remove(self):
if( Book==[ ]):
print(“Stack Empty. Underflow”)
else:
print(“Deleted book is :”, Book.pop())
(OR)
Write a function called letter_freq(my_list) that takes one parameter, a list
of strings(mylist) and returns a dictionary where the keys are the letters
from mylist and the values are the number of times that letter appears in the
mylist, e.g.,if the passed list is as:
wlist=list(“aaaaabbbbcccdde”)
then it should return a dictionary as{‘a’:5,’b’:4,’c’:3,’d’:2,’e’:1}
Ans. def letter_freq(mylist):
d={ }
for i in mylist:
if i not in d:
d[i] =mylist.count(i)
return d
wlist=list(‘aaaaabbbbcccdde”)
R=letter_freq(wlist)
print(R)
S.NO SECTION-D MARKS
31 Learn Together is an educational NGO. It is setting up its new campus at 5
Jabalpur for its web-based activities. The campus has four compounds as
shown in the diagram below:

Centre to centre distance between various compounds as per architectural


drawing (in m) is as follows:
BLOCK DISTANCE
Main Compound to Resource Compound 110 m
Main Compound to Training Compound 115 m
Main Compound to Finance Compound 35 m
Resource Compound to Training Compound 25 m
Resource Compound to Finance Compound 135 m
Training Compound to Finance Compound 100 m
Expected number of computers in each compound are as follows:
BLOCK NO.OF COMPUTERS
Main Compound 5
Resource Compound 15
Training Compound 150
Finance Compound 20
(i)Suggest a cable layout of connections between the compounds.
(ii) Suggest the most suitable place (i.e. compound) to house the server for
this NGO. Also, provide a suitable reason for your suggestion.
(iii) Suggest the placement of the following devices with justification:
(a) Repeater (b) Hub/Switch
(iv) The NGO is planning to connect its international office situated in
Mumbai, which out of the following wired communication link, will you
suggest for a very high-speed connectivity?
(a) Telephone analog line (b) Optical fibre (c) Ethernet cable.
(v) Suggest a device / software to be installed in the Jabalpur campus to
take care of data security.
Ans. (i) Main-Finance-Training-- Resource
(ii) Training compound which has more no.of computers
(iii) Repeater: as per one layout the repeater can be avoider as all distances
between the compounds as less than 100m
Hub/Switch: Training compound as it has hosting server
(iv) Optical fibre
(v) Firewall
32 (a) Write the output of the code given below: 2+3
def evn(l):
enum=” “
for n in range(len(l)):
if n%2==0:
enum+=l[n]
elif n%3==0:
enum+=l[n].upper( )
return enum
print(evn([‘a’,’b’,’r’,’a’,’c’,’a’,’d’,’a’,’b’,’r’,’a’]))
Ans. arAcdbRa
(b) The given program is used to connect with MYSQL and show the name
of all the database available in MYSQL server. You are required to
complete the statements so that the code can be executed properly.
import mysql.connector
db=mysql.connector.________(i) fill the statement with appropriate method
(host=”localhost”,user”root”,password=”smsmb”)
cur=db.cursor( )
cur.execute(“_______;”) (ii) command to display all the database name
print(cur.________) (iii) method to extract all the required from the cursor
Ans.(i) connect (ii) show databases (iii) fetchall( )
(OR)
(a) Predict the output of the code given below:
a=10
b=20
def change( ):
global b
a=45
b=56
change( )
print(a)
print(b)
Ans. 10
56
(b) Write a function to find the power of a number.
Ans. def power(x,y=2):
r=1
for i in range(y):
r=r * x
return r
print(power(3))
print(power(3,3))
33 (a) Write a function in Python that counts the number of “Me” or “My” 5
words present in a text file “STORY.TXT”. If the “STORY.TXT” contents
are as follows:
My first book was Me and My family.
It gave me chance to be known to the world.
The output of the function should be:
Count of Me/My in file:
Ans. def displayMeMy( ):
num=0
f=open(“story.txt”,”rt”)
N=f.read( )
M=N.split( )
for x in M:
if x==”Me” or x==”My”:
print(x)
num=num+1
f.close( )
print(“Count of Me/My in file:”,num)
(b) Give one point of difference between a binary file and a CSV file.
Ans. Binary file: extension is .dat; not human readable; stores data in the
form of 0s and 1s
CSV file: extension is .csv; human readable; stores data like a text file
(OR)
(a) What are functions? Give its advantages.
Ans. Functions are a set of statements works on a data and often returns a
value. Ad: Reusability of code; reduce space and time; increases readability
(b) Write a function in Python PUSH(Arr), where Arr is a list of numbers.
From this list push all numbers divisible by 5 into a stack implemented by
using a list. Display the stack if it has at least one element, otherwise
appropriate error message.
Ans. def PUSH(Arr,value):
s=[]
for x in range(0,len(Arr)):
if Arr[x]%5==0:
s.append(Arr[x])
if len(s)==0:
print(“Empty stack”)
else:
print(s)
S.NO SECTION-E MARKS
34 In a database High sports there are two tables: students and sports with the 4
instances given below:
Table: STUDENTS
ADMNO NAME CLASS GRADE RNO ADDRESS PHONE
1211 MEENA 12A D 4 A-26 3245678
1212 VANI 10A D 1 B-25 5456789
1213 MEENA 12B A 1 NULL NULL
1214 KARISH 10B B 3 AB-234 4567890
Table: SPORTS
ADMNO GAME COACHNAME GRADE
1215 CRICKET MR.RAVI A
1213 VOLLEYBALL MR.AMANDEEP B
1211 VOLLEYBALL MR.GOVARDHAN A
1212 BASKETBALL MR.TEWARI B
Write the SQL queries for the following statements:
(i) To display name and game of those students whose address is available
in students table.
(ii) To delete a column phone from the table students.
(iii) To display names of those students who are studying in class 12 and
their corresponding coach names is their admission number.
(OR) (Option for part iii only)
(iii) To count the number of students who play volleyball.
Ans. (i) Select name, game from students,sports where
students.admno=sports.admno and address is not null;
(ii) alter table students drop phone;
(iii) select name,coachname from students,sports where class like “12%”
and students.admno=sports.admno;
(OR)
(iii) select count(*) from students,sports where game=”volleyball” and
students.admno=sports.admno;
35 Krishna of class 12 is writing a program to read the details of Sports 4
performance and store in the csv file “games.csv” delimited with a tab
character. As a programmer, help him to achieve the task.
import csv
f=open(“games.csv”,”a”)
sobj=csv.________(f.delimiter=’\t’) # Line 1
sobj.writerow([‘Games’,’Competitions’,’Prizes’])
ans=’y’
i=1
while ans==’y’:
print(“Record:”i)
game= input(“Game Name:”)
comp=int(input(“No.of participants:”))
prize=int(input(“Prizes:”))
rec=_________ # Line 2
sobj._________ # Line 3
i+=1
ans=input(“Do you want to continue?(y/n):”)
f.________ # Line 4
(a) Line 1: To create an object to enable to write in the csv file
(b) Line 2: To store the data in list
(c) Line 3: To write a record
(d) Line 4: To close the file
Ans. Line1: csv.writer
Line2: rec=[sport,comp,prize]
Line3: wobl.writerow(rec)
Line4: f.close( )

You might also like