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

Study Material XII Computer Science

The document provides a sample question paper for Class XII Computer Science annual examination for the year 2022-23. It contains 5 sections with a mix of short, long, and very short answer type questions. Section A has 18 one mark questions, Section B has 7 two mark questions, Section C has 5 three mark questions, Section D has 3 five mark questions, and Section E has 2 four mark questions with one internal choice in question 35.

Uploaded by

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

Study Material XII Computer Science

The document provides a sample question paper for Class XII Computer Science annual examination for the year 2022-23. It contains 5 sections with a mix of short, long, and very short answer type questions. Section A has 18 one mark questions, Section B has 7 two mark questions, Section C has 5 three mark questions, Section D has 3 five mark questions, and Section E has 2 four mark questions with one internal choice in question 35.

Uploaded by

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

QUESTION BANK

FOR
ANNUAL EXAMINATION: 2022-23
CLASS-XII
SUBJECT- COMPUTER SCIENCE

FEATURES

MODEL SAMPLE QUESTION PAPER


WITH MARKING SCHEME

REGIONAL TRAINING CENTRE


DAV INSTITUTIONS
ODISHA ZONE
SAMPLE QUESTION PAPER - 1
CLASS- XII
SUB: COMPUTER SCIENCE(083)

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. SectionAhave18questionscarrying01markeach.
4. SectionBhas07VeryShortAnswertypequestionscarrying02markseach.
5. SectionChas05ShortAnswertypequestionscarrying03markseach.
6. SectionDhas03LongAnswertypequestionscarrying05markseach.
7. SectionEhas02questionscarrying04markseach.Oneinternalchoiceisgiven
in Q35against part C only.
8. All programming questions are to be answer during Python Language only.

SECTIONA
1. StateTrueorFalse 1
When you decrement a variable, you subtract a value from it.
2. Which of the following literal has either True or False value? 1
(a)Special Literals (b)Boolean (c)Numeric (d)String
3. Giventhefollowingdictionaries 1

DictE={"BOARD":"CBSE", "Year":2023}
Dictresult={"Total":350,"Pass_Marks":150}

Which statement will merge the contents of both dictionaries?


a. DictE.update(Dictresult)
b. DictE+Dictresult
c. DictE.add(Dictresult)
d. DictE.merge(Dictresult)
4. Considerthegivenexpression: 1
TrueandFalseor not True
Whichofthefollowingwillbecorrectoutputif thegivenexpressionisevaluated?

(a) True
(b) False
(c) NONE
(d) NULL

5. Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0] Which of the following is correct syntax 1


for slicing operation?

a) print(list1[2:])
b) print(list1[:2])
c) print(list1[:-2])
d) all of the mentioned
1
6. Whichofthefollowingmodeinfileopeningstatementresultsor 1
Generatesanerrorifthefiledoesnotexist?

(a) a+ (b)rb+ (c)wb+ (d)Noneoftheabove

7. Fillintheblank: 1

Commandisusedtorename a columnfromthetableinSQL.

(a)update (b)remove (c)alter (d)drop

8. Whichofthefollowingcommandswillchange the row values in theMYSQL table? 1


(a) UPDATETABLE
(b) ORDER BY
(c ) INSERTTABLE
(d) ALTERTABLE

9. Which of the following statement(s) would give an error afterexecutingthe 1


followingcode?

P="I LOVE PYTHON" # Statement


print(P) #Statement2
P="WELCOME" #Statement3
P[2]='$' #Statement 4
print(P[::2])#Statement5
P=P+"WELCOME" #Statement6

(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement4and5

10. Fillintheblank: 1
Constraints does not allow to enter the duplicate values in the
rows and can be given multiple times.
(a) PrimaryKey
(b) ForeignKey
(c) Not Null
(d) Unique

11. Thecorrectsyntaxofseek() with 20 bytes from the current position : 1


(a) file_object.seek(20,2)
(b) seek(20,1)
(c) seek(20,file_object)
(d) seek.file_object(20)

2
12. Fillintheblank: 1
The_______________statementwhencombinedwith table name returnsthe
structure of the table contents.

(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL

13. Fillintheblank: 1
Isacommunicationmethodologydesignedtodeliverbothvoice
andmultimediacommunicationsoverInternetprotocol.

(a)PPP (b)SMTP (c)VoIP (d)HTTP

14. WhatwillthefollowingexpressionbeevaluatedinPython? 1
print(16.0 // 2 + (7 * 4.0))

(a)36.10 (b)31 (c)36.0 (d)38.0

15. Whichfunctionisusedtodisplaythetotalnumberofrecordsfrom 1
Tableinadatabase?
(a) sum(*)
(b) count()
(c) count(*)
(d) return(*)

16 Which method of cursor class is used to fetch limited rows from the table ? 1

(a) cursor.fetchsize(size)
(b) cursor.fetchmany(size)
(c) cursor.fetchall(size)
(d) cursor.fetchonly(size)

Q17and18areASSERTIONANDREASONINGbasedquestions.Markthecorrect
Choiceas
(a) BothAandR aretrueand Risthe correct explanation for A
(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTruebutRisFalse
(d) Aisfalse butRisTrue
17. Assertion(A):-A parameter having a default value in function header becomes 1
optional in Function call.

Reasoning(R):-In function header,any parameter can not have a default value


unless all parameters appearing on its left have their default values.

3
18. Assertion(A):CSV(CommaSeparatedValues)isafileformatfordata 1
Storagewhich lookslikeanASSCII file .
Reason(R):Theinformationisorganizedwith more than
onerecordoneachlineandeach fieldisseparated bycomma.

SECTIONB

2
19. R. Rajguru has written a code to input a range and print the Fibonacci series.
His code is having errors. Rewrite the correct code andunderlinethe correction
made.

Deffibo(n)
a=1,b=1
print(a,b)
foriinrange(2,n1+1):
c=a+b
print(c)
a=c
b=c

20. WritetwopointsofdifferencebetweenBus topology and Star topology. 2

OR

WritetwopointsofdifferencebetweenCDMAandWLL.

21. (a) GivenisaPythonstringdeclaration: 1


CBSE="##ANNUAL Examination2023##"

Writetheoutputof:print(CBSE[::-3])
1
(b) Writetheoutputofthecodegivenbelow:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict)
my_dict.popitem()
print(my_dict)

2
22. Explaintheuseof„ForeignKey‟inaRelationalDatabaseManagement
System.Giveexampletosupportyouranswer.

4
23. (a) Writethefullformsofthefollowing: 2
(i) EDGE (ii)SMTP

(b) Write the disadvantage of TwistedPair over Coaxial Cable?

24. PredicttheoutputofthePythoncodegivenbelow: 2

def CALC (P1,P2):

if P1>P2:
return P1-P2
else:
returnP2-P1

N=[20,25,18,64,42]
for CP in range (3,0,-2):
A=N[CP]
B=N[CP-1]
print(CALC(A,B),'@',end='')

OR

PredicttheoutputofthePythoncodegivenbelow:

T1 = (11, 22, 33, 44, 55 ,66)


L1 =list(T1)
NL = [ ]
for i in T1:
if i%2==0:
NL.append(i)
NT = t(„temp.dat‟, „wb‟uple(NL)
print(NT)
25. DifferentiatebetweenGroup byandOrder byfunctionsinSQLwith 2
Appropriate example.

OR

CategorizethefollowingcommandsasDDLorDML:
CREATE VIEW,GROUP BY, DROP, ALTER,SELECT

SECTIONC

26. (a)Considerthefollowingtables–Customer_Details andDepartment: 1+2


Table:Customer_Details

AC Name SType
A01 Smrita Savings
A02 Rarthodas Current
A03 Niraben Current

5
Table:Department
AC Location

A01 Delhi
A02 Mumbai
A01 Nagpur

Whatwillbetheoutputofthefollowingstatement?

SELECT*FROMCustomer_DetailsNATURALJOINDepartment;

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

Table:MY_SUBJECT

ID NAME AMOUNT DURATION PID


C201 AnimationandVFX 12000 2022-07-02 101
C202 CADD 15000 2021-11-15 NULL
C203 DCA 10000 2020-10-01 102
C204 DDTP 9000 2021-09-15 104
C205 MobileApplication 18000 2022-11-01 101
Development
C206 Digitalmarketing 16000 2022-07-25 103

(i) SELECTDISTINCTPIDFROMMY_SUBJECT;

(ii) SELECT PID, COUNT(*), MIN(AMOUNT) FROM

MY_SUBJECT GROUPBYPIDHAVINGCOUNT(PID)>1;

(iii) SELECT NAME FROM MY_SUBJECTWHERE

AMOUNT >15000ORDERBYNAME;

(iv) SELECTAVG(AMOUNT)FROMMY_SUBJECT WHERE

AMOUNT BETWEEN15000AND17000;

6
Q27 WriteamethodCOUNTLINES()inPythontoreadlinesfromtextfile 3
„EXAMFILE.TXT‟ and display the lines which are starting with „W‟ and „A‟.

Example:

Ifthefilecontentisasfollows:

Anappleadaykeepsthedoctoraway.
Weallprayforeveryone‟ssafety.
Amarkeddifferencewillcomeinourcountry.
Hello ! I am here.

TheCOUNTLINES()functionshoulddisplaytheoutputas:
The no. of lines starting with W is -1
The no. of lines starting with A is - 2

OR

Write a function WordCount() in Python, which should read eachword of a text


file “TESTFILE.TXT” and then count and displaythe count of occurrence of“is”
present in the file.

Example:

Ifthefilecontentisasfollows:

Todayisapleasantday.It is likely torain today.


It is mentionedonweathersites.

TheWordCount()functionshoulddisplaytheoutputas:
No of words containing “is” are - 3

Q28 (a)WritetheoutputsoftheSQLqueries(i)to(iv)basedontheRelationsEMP 3
andJOB_DETAILSgivenbelow:

Table:EMP
T_ID Name Age Department Date_of_join Salary Gender
1 Arunan34ComputerSc2019-01-101 2000 M
2 Saman31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4Samira 35 History 2018-07-01 40000 F
5 Raman 42 Mathematics 2021-09-05 25000 M
6 Shyam50 History 2019-06-27 30000 M
7 Shiv 44 Computer Sc2019-02-25 21000 M
8 Shalakha33 Mathematics 2018-07-31 20000 F

Table:JOB_DETAILS
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 ComputerSc Nagpur

7
(i) SELECTDepartment,avg(salary)FROM EMP GROUPBYDepartment .
ii)SELECTMAX(Date_of_Join),MIN(Date_of_Join)FROM EMP;
iii)SELECTName,Salary,Department, Place FROM EMP T, JOB_DETAILS P
WHERE T.Department = P.Department AND Salary>20000;

iii) SELECTName,PlaceFROMEMP T,JOB_DETAILSJ WHEREder=‟F‟ANDT.


Department=J.Department;
(iv)Writethecommandtoviewalltablesinadatabase.

Q29
WriteafunctionODD_LIST(M),whereListhelistofelementspassed as argument
. 3
tothefunction.Thefunctionreturnsanotherlistnamed„indexList‟
thatstorestheindicesofallodd Elementsof M.

Forexample:

IfMcontains[12,4,0,11,41,56,3]

TheODD_LISTwillhave[3,4,6]

Q30 A list contains following record of a customer:[EMP_name,Age,Salary]

Write the following user defined functions to perform given operationsonthe stack 3
named„Grade’:
i) Push_Item()-ToPushanobjectcontainingnameandageofEmployeeswhose
salary is >=3000tothestack.
ii) Pop_Item() - To Pop the objects from the stack anddisplay them. Also,
display “Stack Empty” when there are noelementsin the stack.

The output should be:


[“AMAN”,34,4000]
[“SIMRAN”,19,3500]
StackEmpty

OR

Write a function in Python, Push(DELEMENT) where , DELEMENT is a


dictionarycontainingthedetailsof Electronicitems–{Ename:Qty}
The function should push the names of those items in the stack
whohaveQtygreaterthan200 .Alsodisplaythecountofelementspushedintothe stack.

Forexample:Ifthedictionarycontainsthefollowingdata:

DELEMENT={"Mouse":250,"Keyboard":200,"Laptop":350,"Printer":20}
ThestackshouldcontainMouse
Laptop

Theoutputshouldbe:
Thecountofelements inthe stack is2
SECTIOND
8
31. MakeInIndiaCorporation,anUttarakhandbasedITtrainingcompany,is planning to
set up training centres in various cities in next 2
years.TheirfirstcampusiscomingupinKashipurdistrict.AtKashipurcampus,theyare
planningtohave3differentblocksforAppdevelopment,WebdesigningandMovieedit
ing.Eachblockhasnumberofcomputers,whicharerequiredtobeconnectedinanetwor
k for communication, data and resource sharing.As a networkconsultant of this
company, you have to suggest the
bestnetworkrelatedsolutionsforthemforissues/problemsraisedinquestionnos.(i)
to(v),keepinginmindthedistancesbetween various blocks/locationsandother
givenparameters.

App Kashipur
Development Campus Movie
Mussoorie Editing
Campus
Web
Designing

Distancebetween variousblocks/locations:

Block Distance
App development toWebdesigning 28m
AppdevelopmenttoMovieediting 55m
WebdesigningtoMovie editing 32m
KashipurCampustoMussoorieCampus 232km

Numberofcomputers
Block Number of
ComputersAppdevelopment 75
Webdesigning 50
Movieediting 80

(i) Suggest the most appropriate block/location to house


theSERVERintheKashipurcampus(outofthe3blocks)togetthebestandef 1
fectiveconnectivity.Justifyyouranswer.
(ii) Suggestadevice/softwaretobeinstalledintheKashipurCampusto 1
takecareofdatasecurity.
(iii) Suggestthebestwiredmediumanddrawthecablelayout(Block
toBlock)toeconomicallyconnectvariousblockswithinthe 1
KashipurCampus.

9
(iv) Suggesttheplacementofthefollowingdeviceswithappropriatereasons:
a. Switch/Hub
1
b. Repeater
(v) Suggest a protocol that shall be needed to provide
VideoConferencingsolutionbetweenKashipurCampusandMussoorieCa
mpus. 1

32. (a) Writetheoutputofthecode givenbelow: 2+3

A= 7
def sum(M, N=4):
global A
A=N+M**2
print(A,end='#')

X,Y=10,5
Y=sum(X,Y)
sum(N=9,M=2)

(b) ThecodegivenbelowinsertsthefollowingrecordinthetableStudent:

RollNo –
integerName –
stringClass –
integerMarks–
integer

NotethefollowingtoestablishconnectivitybetweenPythonandMYSQL:
 Usernameisroot
 Passwordistiger
 ThetableexistsinaMYSQLdatabasenamedschool.
 The details (RollNo, Name, Class andMarks) are to
beaccepted fromtheuser.
Writethefollowingmissingstatementstocompletethecode:
Statement1– to formthecursor object
Statement2–toexecutethecommandthatinsertstherecordinthetableStudent.
Statement3-toaddtherecordpermanentlyinthedatabase

importmysql.connectorasmysql

defsql_data():
obj=mysql.connect(host="localhost",user="root", password="tiger",
database="school")
mycursor= #Statement1
10
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
clas=int(input("Enter class :: "))
marks=int(input("Enter Marks :: "))
query="insertintostudent
values({},'{}',{},{})".format(rno,name,clas,marks) #Statement2
__________________________ #Statement3

print("DataAddedsuccessfully")

OR

(a) Predicttheoutputofthecodegivenbelow:

s="My School@"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m=m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

(b) Thecodegivenbelowreadsthefollowingrecordfromthetablenamed student


and displays only those records who havemarksgreaterthan85:
RollNo–integer
Name – string
Clas – integer
Marks–integer

Note the following to establish connectivity between Python andMYSQL:


 Usernameisroot
 Passwordistiger
 ThetableexistsinaMYSQLdatabasenamedschool.

Writethefollowingmissingstatementstocompletethecode:
Statement1– to formthecursor object
Statement 2 – to execute the query that extracts records of those studentswhose
marksare greaterthan 85.
Statement3-toreadthecompleteresultofthequery(recordswhose marks are greater
than 85) into the object named data, from the tablestudent inthedatabase.

importmysql.connectorasmysql
defsql_data():

con1=mysql.connect(host="localhost",user="root",password="tiger",
11
database="school")
mycursor = #Statement 1
print("Studentswithmarksgreaterthan85are:")
___________________________ #Statement2
data= #Statement 3
foriindata:
print(i)
print()

a)Whatistheadvantageofusingacsvfileover text file ?


b)WriteaPrograminPythonthatdefinesandcallsthefollowinguser defined
functions:

(i) APPEND() – To accept and add data of an employee to a CSV


file„Myrecord.csv‟. Each record consists of a list with field
elementsasEmpNo, NameandPhone tostoreEmployeeNo,EmployeeName
33. andEmployee Phone no. respectively.
5
(ii) RECCOUNT()–Tocountthenumberofrecordspresent intheCSVfile
named„Myrecord.csv‟.
OR

Give any one point of difference between a binary file and a csv file.

Write a Program in Python that defines and calls the following


userdefinedfunctions:

(i) AddRecord() – To accept and add data of an employee to a


CSVfile „furdata.csv‟. Each record consists of a list with
fieldelementsasfid, fnameandfpriceto
storefurnitureid,furniturenameandfurniturepricerespectively.

(ii) SearchRecord()-Todisplaytherecordsofthefurniturewhose
Priceismorethan 3500.

12
SECTIONE
34. Sandeep creates a table RESULT with a set of records to maintainthe marks 1+1+2
secured by students in Sem 1, Sem2, Sem3 and theirdivision. After creation of
the table, he has entered data of 7studentsin the table.

SID SNAME SEM1 SEM2 SEM3 DIVISION

101 KARAN 366 410 402 I


102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II

107 NEELAM 470 450 471 I

Basedonthedatagivenaboveanswerthefollowingquestions:

(i) Identify the most appropriate column, which can be considered


asPrimary key.

Iftwocolumnsareaddedand2rowsare deletedfromthetableresult,
Whatwill bethenew degreeandcardinalityoftheabovetable?

(ii) Writethestatementsto:
a. Insertthefollowingrecordintothetable
SID- 108, SName- Radit, Sem1- 470, Sem2-444, Sem3-475,Div– I.
b. IncreasetheSEM2marksofthestudentsby4%whose
Namebeginswith „P‟.
OR(Optionforpartiiionly)

(iii) Writethestatementsto:
a. DeletetherecordofstudentssecuringIVdivision.
b. Change the columnname DIVISION to GRADE inthetable.

13
35. Sangram is a Python Expert Programmer. He has written a code and created 4
abinaryfilerecord.datwithemployeeid,enameandsalary.Thefilecontains12records.
Henowhastoupdatearecordbasedontheemployeeidenteredbythe user and update the
salary. The updated record is then to bewritten in the file temp.dat. The records
which are not to beupdated also have to be written to the file temp.dat. If
theemployee id is not found, an appropriate message should to bedisplayed.
AsaPythonexpert,helphimtocompletethefollowingcodebasedonrequirement
givenabove:

import #Statement1
defupdate_data():
rec={}
FIN=open("record.dat","rb")
FW=open(" _________________ ") #Statement 2
found=False
eid=int(input("Enteremployeeidtoupdatetheir salary :: "))
whileTrue:
try:
rec= #Statement 3
ifrec["Employeeid"]==eid:
found=True
rec["Salary"]=int(input("Enternewsalary ::"))
pickle. #Statement4
else:
pickle.dump(rec,fout)
except:
break
iffound==True:
print("The salary of employee id",eid,"hasbeenupdated.")
else:
print("Noemployeewithsuchidisnotfound")
FIN.close()
FW.close()

(i) Which module should be imported in the program? (Statement1)


(ii) Writethecorrectstatementrequiredtoopenatemporaryfilenamed
temp.dat(Statement 2)
(iii) WhichstatementshouldSangramfillinStatement3toreadthedata from the
binary file, record.dat and in Statement 4 towritetheupdateddatainthe
file,temp.dat?

14
SAMPLE QUESTION PAPER (2022-23)
CLASS- XII
SUB: COMPUTERSCIENCE(083)
MARKING SCHEME - 1
Time Allowed: 3 Hours Maximum Marks: 70
QST Value Points Marks
Allotted
N
NO
1 Ans.TRUE 1

2 Ans.(d) TRUE 1

3 Ans:(d)del colors[“Blue”] 1
4 Ans:(b)False 1
5 Ans:(c) „abcdedede‟ 1
6 Ans:(b)fobj.readline() 1
7 Ans (c) drop 1
8 Ans: (b) DROP VIEW 1
9 Ans:(c) - Statement3 and 4 1
10 Ans:(d)Alternate Key 1
11 Ans:(d)os 1
12 Ans:(c) Order by 1
13 Ans:(b)IP 1
14 Ans:(a)14.75 1
15 Ans:(d) None 1
16 Ans:(b)–Database 1
17 Ans:(c)A is True but R is False 1
18 Ans:(c) A is True but R is False 1
19 Ans: 2
def Check():
n = int(input("Enter a number "))
for k in range (1,n//2) : : missing
if k*k == n: = missing
print("Square root = ",k)
break
if k == n // 2-1: / missing
print("Not a perfect square ") “ missing

Check()

(½mark for each correct correction made and underlined.)


20 Ans: 2
Client Side Script Server Side Script
It is downloaded and run It runs at server end and result is send
at client end. to client end(browser)

It is browser dependent It is not browser dependent

Exp- JavaScript, VB Script Exp- ASP, JSP

(1mark for each correct point of difference)


OR
Ans:
Coaxial Cable –
Advantage – It provides a cheap means of transporting multi-channel television
signals around metropolitan areas.
Disadvantage – It is an expensive communication medium.

Optical Fibre –
Advantage – It is free from electrical noise and interference.
Disadvantage – It is costly and fragile.

(½mark for each correct advantage and ½ mark for each correct disadvantage.)

21 a. Ans: git 2
(1mark for the correct answer)

b. Ans:dict_values([111, 200, 'AAA'])


(1mark for the correct answer)
22 Ans: 2
Degree – Total number of columns / attributes in a relation.
Cardinality – Total number of rows in a relation.
(1 mark for correct definition of Degree, 1 mark for correct definition of
Cardinality)
23 a. Ans: 2
(i) IMAP:Internet Message AccessProtocol
(ii) POP:Post OfficeProtocol
(½ mark for every correct full form)
b. Ans:VoIP refers to a way to carry telephone calls over an IP data net work.
It offers a set of facilities to manage the delivery of voice information over
Internet in digital form.
(1mark for correct answer)
24 Ans: 9 60 PSRSSS 2
(1mark for 9 60 and 1 mark for PSRSSS)
OR
Ans: (77, 88, 55, 22, 44, 11)

(½ markfor each 2 correct digits of output ½ mark for parenthesis)


25 Ans: Delete command deletes records from a table where as Drop command 2
deletes an entire table / view.
Delete keeps the structure of the table intact but Drop deletes it.
Delete is a DML command but Drop is a DDL command.
(1 mark for each correct difference. Any 2 differences needed)
OR
DDL commands – DELETE, CREATE
DML commands – INSERT, SELECT
(½ mark for each correct answer)
26 Ans: 3
(a)
EmpCode Name Desig Area
E001 Amartya Mgr Delhi
E001 Amartya Mgr Noida
E002 Kim Exec Chandigarh
(1markforcorrect output)
(b)
(i) 50 (ii) 40 (iii) 72500

(iv) Shivam travels


Anand travels
Bhalla Co.
Yadav Co.
Speed travels
Kisan Tours
(1/2 mark for each correct answer)
27 Ans: 3
defCOUNTLINES():
file=open('TESTFILE.TXT','r')
lines=file.readlines()
count=0
forwinlines:
if (w[-1] not in '0123456789':
count=count+1
print("Thenumberoflines= ",count)
file.close()
COUNTLINES()
(½mark for correctly opening and closing the file
½for read lines()
½mark for correct loop
½for correct if statement
½mark for correctly incrementing count
½mark for displaying the correct output)
OR
Ans:
defCount():
file=open('MYTESTFILE.TXT','r')
str=file.read()
countis=0
countare=0
words = str.split()
for w in words :
ifw==‟is':
countis = countis + 1
if w==‟are‟:
countare=countare+1
print ("count of is : ", countis)
print (“count of are : ", countare)
file.close()
(½mark for correctly opening and closing the file
½for split()
½mark for correct loop
½for correct if statements
½mark for correctly incrementing counts
½mark for displaying the correct output)
Note: Any other relevant and correct code may be marked
28 Ans. (a) 2+1
(i) select Firstname, Lastname, Address, City from Employee where City =
„Paris‟;
(ii) Select Firstname, Lastname, Salary+Benefits from Employee, Empsalary
Where Employee.Empid = Empsalary.Empid;
(iii) Select Max(Salary) from Empsalary where Designation = „Manager‟ or
Designation = „Clerk‟
(1 mark for each correct answer)
Ans: (b)
SHOWTABLES;
(1markforcorrectanswer)

29 Ans: 3

defNEW_LIST(L):
NewList=[]
for i in L:
ifi>=1000 and i<=9999:
NewList.append(i)
returnNewList
(½ mark for correct function header
1mark for correctloop
1mark for correct if statement
½markforreturnstatement)
Note: Any other relevant and correct code may be marked
30 status=[] 3
def Push_element(book):
ifbook[1]=="Comp Sc":
L1=[cust[0],cust[2]]mybooks.append(L1)

def Pop_element ():num=len(mybooks)


while
len(mybooks)!=0:dele=mybooks.pop()print(d
ele)
num=num-1
else:
print("StackEmpty")
(1.5 marks for correct push_element() and 1.5 marks for
correctpop_element())
OR
stackItem=[]
def Push(SItem):
count=0
forkinSItem:
if
(SItem[k]>=75):stackItem.append(k)count=cou
nt+1
print("Thecountofelementsinthestack
is:",count)

(1 mark for correct function header1mark


for correctloop
½markforcorrectIfstatement
½mark forcorrectdisplayof count)
Note: Any other relevant and correct code may be marked
31 Ans. 4
a. Bus network (A to B, A to C, C to D)
b. Hub/Swich – in each building
c. Wan
d. Building C, as maximum number of computers are there.
(1 mark for each correct answer)

32 a. Ans: 6
Output:
105#6#
(1 markfor105#and1markfor6#)
b. Ans:

Ans:
Statement1:
con1.cursor()

Statement 2:mycursor.execute(querry)

Statement3:
con1.commit()

(1markforeachcorrectanswer)
OR
a. Ans:
SsHhOo##CcM

(1markforfirst5characters,1markfornext6characters)

b. Ans:
Statement1:
con1.cursor()
Statement2:
mycursor.execute("select*fromstudentwhereMarks>75")
Statement3:

mycursor.fetchall()
(1markforeachcorrectstatement)
33 Ans: 2
The csv.reader object reads data from a csv file on storage disk, removes the
delimitation and loads the data into a Python iterator wherefrom the data
can be fetched row by row.

Program:
import csv
defWrite():
fout=open("record.csv","a",newline="\n")wr=csv.writer(fout)
roll=int(input("EnterRoll::"))
name=input("EnterName::")
aggregate=int(input("EnterAggregate::"))
lst=[roll,name,aggregate]---------1/2mark
wr.writerow(lst) ---------1/2 markfout.close()

defCount():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
ctr=0
for i in data:
if [2]>75:
ctr = ctr+1
print(ctr)
fin.close()

Write()
Count()
(1mark for correct definition of csv.reader()
½mark for importing csv module
1 ½marks each for correct definition of Write()and Count()
½mark for function call statements)
OR

Ans:
Differencebetweenbinaryfileandcsvfile:
(Any1differencemaybegiven)
Binaryfile:
 Extensionis.dat
 Nothumanreadable
 Storesdataintheformof0sand1s
CSVfile
 Extensionis.csv
 Humanreadable
 Storesdatalikeatextfile
Program:
importcsv
defadd():
fout=open("book.csv","a",newline='')
wr=csv.writer(fout)
bid=int(input("Enter Book Id::"))
bname=input("Enter Book name :: ")
bprice=int(input("Enter Book price :: "))FD=[bid,bname,bprice] ---------
1/2mark
wr.writerow(FD)---------1/2mark
fout.close()
defsearch():
fin=open("book.csv","r",newline='')
data=csv.reader(fin)
print("The Details are")
foriindata:
print(i)
fin.close()
add()
search()
(1mark for difference
½markfor importingcsvmodule
1½markseachforcorrectdefinition of add()and search()
½markfor function call statements)
34 2
Ans:
(i) ROLL_NO

(1markforcorrectanswer)
(ii)
NewDegree:8
NewCardinality:5
(1/2markforcorrectdegreeand½markforcorrectcardinality)

Ans:
a. INSERTINTORESULTVALUES(108,„Aadit‟,470,444,475,„I‟);
b. UPDATERESULTSETSEM2=SEM2+(SEM2*0.03)WHERESNAMELIKE
“N%”;
(1markforeachcorrectstatement)

OR
Ans:
a. DELETEFROMRESULTWHEREDIV=‟IV‟;
b. ALTERTABLERESULTADD(REMARKSVARCHAR(50));
(1markforeachcorrectstatement)

35 (i) Ans:pickle 2
(1markforcorrectmodule)
(ii) Ans: fout=open(„stu.dat‟, „wb+‟)
(1markforcorrectstatement)
(iii) Ans:Statement3:pickle.load(fin)
(1markforcorrectstatement)
(iv) fin.seek(rpos)
(1markforcorrectstatement)
SET NO - 1/2/3

Roll No. Candidates must write the Set No. on


the title page of the Answer Sheet.

SAMPLE QUESTION PAPER – 2 (2022-23)

 Please check that this question paper contains 14 printed pages.


 Set number given on the right-hand side of the question paper should be written on
the title page of the answer book by the candidate.
 Check that this question paper contains 35 questions.
 Write down the Serial Number of the
(Theory: question in the left side of the margin before
Pre-Term-1)
attempting it.
 15 minutes time has been allotted to read this question paper. The question paper
will be distributed 15 minutes prior to the commencement of the examination. The
students will read the question paper only and will not write any answer on the
answer script during this period.

CLASS-XII

SUB:COMPUTER SCIENCE (083)

Time Allowed: 3 Hours Maximum Marks: 70

General Instructions:

 This question paper contains five sections, Section A to E.


 All questions are compulsory.
 Section A has 18 questions carrying 01 mark each.
 Section B has 07 Very Short Answer type questions carrying 02 mark each.
 Section C has 05 Short Answer type questions carrying 03 mark each.
 Section D has 03 Long Answer type questions carrying 05 mark each.
 Section E has 02 questions carrying 04 mark each. One internal choice is given
in Q35 against part c only.
 All programming questions are to be answered using Python Language only.
 All programming questions are to be answered using Python language only.

Sample Question Paper/CSC-XII/SET-I Page 1 of 14


SECTION-A
1 State True or False. 1
“The # symbol used for inserting comments in Python is a token”.
2 Find the datatype of „A‟ in the following statement. 1
A=100-10,100,10,10+100,10*100
(a) list (b) tuple (c) integer (d) Error
3 Given the following dictionary: 1
D={'B':'Black','R':'Red','B':'Blue'}
Find the value of D1:
D1=dict.fromkeys(D)
(a) {'B': None, 'R': None, 'B': None}
(b) {'Black': None, 'Red': None, 'Blue': None}
(c) {'B': ' ', 'R': ' '}
(d) {'B': None, 'R': None}
4 Consider the given expression: 1
not True and not False or not not False and not True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False (c) None (d)Error in the code
5 Select the correct output of the code: 1
a='AISSCE 2023'
b=len(a.split('S')+list(a.partition(' ')))
print(b)
(a) 4 (b) 5 (c) 6 (d) 7
6 Which of the following is not a correct Python statement to open a binary file Notes.dat 1
to write content into it?
(a) F=open('Notes.dat', 'wb')(c) F=open('Notes.dat', 'rb')
(b) F=open('Notes.dat', 'wb+')(d) F=open('Notes.dat', 'rb+')
7 Fill in the blank: 1
______ command is used to change the price of a product.
(a) UPDATE (b) ALTER (c) CREATE (d) RENAME
8 Which SQL command is used to remove row(s) from the table Student? 1
(a) Drop Table Student

Sample Question Paper/CSC-XII/SET-I Page 2 of 14


(b) Drop From Student
(c) Delete * From Student
(d) Delete From Student
9 Which of the following statement(s) would give an error after executing the following 1
code?
def prod (int a): #Statement 1
d=a*a #Statement 2
print(d) #Statement 3
return prod #Statement 4
(a) Statement 1 and Statement 2(c) Statement 1 and Statement 4
(b) Statement 1 and Statement 3(d) Statement 2 and Statement 4
10 Fill in the blank: 1
In DBMS, ________ is a candidate key in a relation.
(a) Foreign Key
(b) Alternate Key
(c) Primary Key
(d) All of the above
11 Which of the following statement is correct to position the file pointer at the beginning of 1
the file?
(a) FileObject.seek(0,0)
(b) FileObject.seek(0,1)
(c) FileObject.seek(1,0)
(d) FileObject.seek(0,2)
12 Fill in the blank: 1
_________ command is used to view the structure of the table.
(a) VIEW (b) DESC (c) SELECT (d) SHOW
13 Which unguided transmission media is required to be in line-of-sight distance? 1
(a) Radio Wave
(b) Satellite
(c) Micro Wave
(d) All of the above
14 What will the following expression be evaluated to in Python? 1
print((15//2*3+4)+10%3)
(a) 8 (b) 7 (c) 2 (d) 26

Sample Question Paper/CSC-XII/SET-I Page 3 of 14


15 Which of the following operator is used for pattern matching? 1
(a) BETWEEN(c) IS LIKE
(b) HAVING(d) LIKE
16 A resultset is extracted from the database using the cursor object (that has been already 1
created) by giving the following statement.
Mydata=cursor.fetchone()
What will be the datatype of Mydata object after the given command is executed?
(a) tuple(b) list
(c) nested tuple(d) hexadecimal address
Q17 and Q18 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 local and global variables declared with the same name in the function 1
are treated same by the Python interpreter.
Reason (R): The variable declared within the function block is treated to be local variable
whereas, the variable declared outside the function block will be referred to as global
variable.
18 Assertion (A): Python provides a built-in module called csv module to enable reading and 1
writing operation in csv file.
Reason (R): It used mainly the classescsv.writer and csv.reader. The csv.writer class
creates a writer object, whereas the csv.reader class returns a reader object.
SECTION-B
19 Rishi has written a code and his code is having errors. Rewrite the correct code and 2
underline the corrections made.
x=input("Enter a no:-")
if x%2=0:
for i range(2*x):
Print(i)
loop else:
print("#")
20 Write two points of differences between Switch and Hub. 2
(OR)
Write any two points of differences between Star Topology and Bus topology.
Sample Question Paper/CSC-XII/SET-I Page 4 of 14
21 (a) Given is a Python string declaration: 1
S="Cyber World @@ 2022"
Write the output of: print(S.replace('2','2+1')[::-2])
(b) Write the output of the code given below: 1
D={'India':'New Delhi', 'China':'Beijing', 'USA':'Washington DC', 'UK':'London'}
for i in D:
if 'U' in i:
D[i]+='Ok'
for i in D.values():
print(i,end=' ')
22 What is a primary key? What is its significance in a relation? 2
23 (a) Write the full forms of the following: 2
(i) GPRS (ii) XML
(b) What is the use of SMTP?
24 Predict the output of the Python code given below: 2
def div5(n):
if n%5==0:
return n*5
else:
return n+5
def output(m=5):
for i in range(0,m):
print(div5(i),'@',end='')
print()
output(7)
output()
(OR)
Predict the output of the Python code given below:
L='Alexander'
x=''
l1=[]
count=1
for i in L:
if i in ['a','e','i','o','u']:
x=x+i.upper()
Sample Question Paper/CSC-XII/SET-I Page 5 of 14
else:
if count%2!=0:
x=x+str(len(L[:count]))
else:
x=x+i
count+=1
print(x)
25 Differentiate between CHAR and VARCHAR datatype in MySQL with appropriate 2
example.
(OR)
Categorize the following commands as DDL or DML:
CREATE, DELETE, INSERT, DROP
SECTION-C
26 a) Consider the following tableStudent and Record: 1+2
Table: Student
Id Name Class City
3 Hina 3 Delhi
4 Megha 2 Delhi
6 Gouri 2 Delhi
Table: Record
Id Class City
9 3 Delhi
10 2 Delhi
12 2 Delhi

What will be the output of the following statement:


SELECT student.name, student.id, record.class, record.cityFROM studentJOIN record
ON student.city = record.city;
b) Write output of the queries (i) to (iv) based on the table, ORDERS given below:
Table: ORDERS
OrderId CustomerId DateOfOrder Price Qty
BT001 80 03-Jan-2018 45000 10
TRP010 78 10-Mar-2020 51000 5
BQS004 34 19-Jul-2021 22000 2
CM003 23 30-Dec-2016 12000 3
TQ006 81 17-Nov-2019 15000 12
BT006 78 01-Jan-2021 28000 14

Sample Question Paper/CSC-XII/SET-I Page 6 of 14


(i) SELECT SUM(Qty) FROM ORDERS WHERE Price>15000;
(ii) SELECT MAX(DateOfOrder) FROM ORDERS;
(iii) SELECT * FROM ORDERS
WHERE Qty>5 AND OrderId LIKE "T%";
(iv) SELECT DateOfOrder FROM ORDERS
WHERE CustomerId IN (70, 80) ;
27 Write a function COUNT() to count total occurrences of “He” and “She” separately 3
present in a text file “Story.txt”.
For example, if the content of Story.txt is: -

He has a camera. The camera belongs to him.


She has a diamond ring. She likes her ring.

Then the output should be:-


Total number of He=1
Total number of She=2
(OR)
Write a function CountVowelConso() which will calculate the total number of occurrence
of vowels and consonants in a text file „Text.txt‟.
For example, if the content of Text.txt is: -
I like Python Programming.

Then the output should be: -


Total vowels=7
Total consonant=15
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations WORKERS and 2+1
DESIG given below:
Table: WORKERS
W_ID FIRSTNAME LAST GENDER ADDRESS CITY
NAME
102 Sam Tones M 33 Elm St Paris
105 Sarah Ackerman F U.S. 110 New York
144 Manila Sengupta F 24 Friends New Delhi
Street
210 George Smith M 83 First Street Howard
255 Mary Jones F 842,Vine Ave. Losantiville
300 Robert Samuel M 9 Fifth Cross Washington
335 Henry Williams M 12 Moore Boston
Street
403 Ronny Lee M 121 Harrison New York
St.
451 Pat Thompson M 11 Red Road Paris
Sample Question Paper/CSC-XII/SET-I Page 7 of 14
W_ID Salary Benefits Designation DE
010 75000 15000 Manager SI
105 65000 15000 Manager G

152 80000 25000 Director


(i) T
215 75000 12500 Manager
o
244 50000 12000 Clerk dis
300 45000 10000 Clerk pla
335 40000 10000 Clerk y
W_
400 32000 7500 Salesman
ID,
441 28000 7500 salesman
FI
RSTNAME, ADDRESS and CITY of all employees living in New York from the
table WORKERS.
(ii) To display the contents of WORKERS table in ascending order of LASTNAME.
(iii) To display the Minimum SALARY among managers and clerks separatelyfrom
the table DESIG.
(iv) To display FIRSTNAME and SALARY from WORKERS and DESIG Table for
each worker.

(b) Write the command to view all the databases present in the system.
29 Write a function FIND() that takes a nested list L (containing integers only) as its 3
argument. The function returns another list named „MaxList‟ that stores the largest
element of each sub list L.
For example:
If L contains [[8,11,10,12],[5,14,6,7],[2,4,5,19],[3,12,5,12]]
The MaxList will have - [12,14,19,12]
30 A list contains following record of a „Computer‟:[MACAddress, Brand, Price, RAM] 3
Write separate user defined functions to perform given operations on the stack named
„System‟:
(i) Push_element() - To Push an object containing Brand and Price of computers
whoseRAM capacity is more than 4GB.
(ii) Pop_element() - To Pop the objects from the stack and display them. Also, display
“Stack Empty” when there are no elements in the stack.

Sample Question Paper/CSC-XII/SET-I Page 8 of 14


For example:
If the lists of computer details are:

[“M001”, “Lenovo”, 75000, 16]

[“M002”, “HP”, 72000, 8]

[“M003”,”Apple”, 110000, 16]

[“M004”, “Compaq”, 50000, 4]

The stack should contain

[“Lenovo”, 75000]

[ “HP”,72000]

[”Apple”, 110000]

The output should be:

[“Lenovo”, 75000]

[ “HP”, 72000]

[”Apple”, 110000]

Stack Empty

OR

BCCI has created a dictionary containing top players and their runs as key value pairs of

cricket team. Write a program, with separate user defined functions to perform the

following operations:

● Push the keys (name of the players) of the dictionary into a stack, where the

corresponding value (runs) is greater than 49.

● Pop and display the content of the stack.

For example:
If the sample content of the dictionary is as follows:
SCORE={"KAPIL":40, "SACHIN":55, "SAURAV":80, "RAHUL":35, "YUVRAJ":110}
The output from the program should be:
YUVRAJ SAURAV SACHIN

Sample Question Paper/CSC-XII/SET-I Page 9 of 14


SECTION-D
31 TPU University is setting up its academic blocks at Udaipur and is planning to set up a
network. The University has 3 academic blocks and one Human Resource Centre as
shown in the diagram below:

Center to Center distances between various blocks/center is as follows:

(i) Suggest an ideal layout for connecting these blocks/centers for wired connectivity. 1
(ii) Which device will you suggest to be placed/installed in each of these blocks/centers 1
to efficiently connect all the computers within these blocks/centers.
(iii) Suggest the placement of Server in the network with justification. 1
(iv) The university is planning to connect its admission office in Delhi, which is more 1
than 780 km from the university. Which type of network out of LAN, MAN, or WAN
will be formed? Justify your answer.
(v) Suggest the device/ software to be installed in Udaipur campus to take care of data 1
security.
32 (a) Write the output of the code given below: 2+3
def Change(p,q=30):
global s
s=p*q
q=p//q
print(p,'@',q)
return p
p=150
Sample Question Paper/CSC-XII/SET-I Page 10 of 14
s=100
r=Change(p,s)
print(p,'@',s)
(b) A table „Student‟ is created in the database „Performance‟. The fields of „Student‟
table are: [StuID, Name, Class, Total, Grade]. Thereafter, the table is to be interfaced
with Python IDLE to perform certain tasks. The incomplete code is given below:

import mysql.connector as mycon


mydb=mycon.connect(host='localhost', '________', user='root', passwd='twelve')#Line 1
mycursor=mydb.cursor()
mycursor.execute("Select * from Student")#Line 2
________________________#Line 3
for i in record:
print(i)

Now, with reference to the above code, answer the following questions:
(i) What will you fill in Line 1 to complete the statement.
(ii) What will you fill in Line 3 to fetch all the records from the table?
(iii) What necessary change you will perform in Line 2 to display all such names from the
table „Student‟ who have secured Grade A?
OR

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


def change():
Text1="CBSE 2021"
Text2="#"
I=0
while I<len(Text1) :
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 + (Text1[I+1])
else :

Sample Question Paper/CSC-XII/SET-I Page 11 of 14


Text2=Text2 + "*"
I=I+1
print(Text2)
change()
(b) A table is given below with following details:
Database: Certification
Table: Professional
Fields are: Code, Course, Duration, Eligibility, Fee
Based on the above information, the following code is given with some empty lines.
The incomplete code is given below:
import mysql.connector as mycon
mydb=mycon.connect(host='localhost', '________', user='root', passwd='twelve')#Line 1
mycursor=mydb.cursor()
mycursor.execute("Select * from Professional")
record=________________________#Line 2
rc=____________________________#Line 3
print(“First three records of the table are:”,record)
print(“Number of rows in the table”, rc)
for i in record:
print(i)
Write appropriate argument/ statement to be filled in the above blank spaces.
(i) What will you fill in Line 1 to complete the statement.
(ii) Write approprate statement in Line 2 to read first 3 records from the file.
(iii) Write approprate statement in Line 3 to find total number of rows in the table.
33 What is the use of writer object in a csv file. 5
Write a Program in Python that defines and calls the following user defined functions:
ADD(): To add data into the csv file named „Newspaper.csv‟ containing records like
Name, NumberOfPages and Press of all Indian English Newpaper.
SEARCH(): Search a specific newspaper from the file on the basis of its Name. If found,
then display the details of the newspaper, otherwise display the message „No such
newspaper found‟
OR
Give any one point of difference between a binary file and a csv file.

Write a Program in Python that defines and calls the following user defined functions:
ADD(): To add English mark of a student into the csv file named „English.csv‟
containing records like Class, Section and Marks of a student.

Sample Question Paper/CSC-XII/SET-I Page 12 of 14


COUNT(): Read all the records from English.csv. Count and display the number of
students who have secured 90 or above mark in English subject.

SECTION-E
34 Mr. Asmit is the class teacher of Class- XII-C. He created a table named „Student‟ to 1+1+2

store records like StuID, Name, Gender, Age and AvgMark of his section students.

StuID Name Gender Age AvgMark

CB01 Abhijeet Boy 19 87

CB02 Monal Girl 18 91

CB03 Divya Girl 17 89

CB04 Sujata Girl 18 78

CB05 Chirag Boy 18 77

Based on the data given above answer the following questions:

(i) Identify the most appropriate column which can become a Primary Key. Justify your

answer.

(ii) Find the degree and cardinality of the above relation if 5 new students record is added

to the existing records.

(iii) Write the statements to:

a. Insert the following record into the table

CB06, Navneeth, Boy, 18, 80.

b. Increase the AvgMark of all Girls by 3.

OR (Option for part iii only)

(iii) Write the statements to:

a. Delete the record of students whose age is 17.

b. Add a column REMARKS in the table with datatype as varchar with 50 characters.

35 Robin, a software programmer is writing a program to create a CSV file which will

contain ItemID and ItemName for some entries. He has written the following code. As a

Sample Question Paper/CSC-XII/SET-I Page 13 of 14


good friend of Robin, help him to execute the following code successfully:

import csv

def AddItem(ItemID, ItemName):

fin=open(“Item.csv”,__________) #Line 1

csvw=csv.writer(fin)

csvw.writerow([ItemID,ItemName])

fin.close()

def readcontents():

fout=open(“Item.csv”,”r”)

csvr=csv.__________(fout) #Line 2

for rec in csvr:

print(rec[0],rec[1])

fout._____________() #Line 3
1
i) In which mode he should open the file in function AddItem() in Line 1.
1
ii) Which function is required to be used in Line 2 and Line 3.
2
iii) How to perform the following operation?

• to call the function AddItem() to add an item detail 101, “Sofa” .

• to display the entire content of the CSV file by calling the function readcontents().

Sample Question Paper/CSC-XII/SET-I Page 14 of 14


Class: XII Session: 2022-23
Computer Science (083)
Marking Scheme - 2

Maximum Marks: 70 Time Allowed: 3 hours


SECTION A
(1 mark to be awarded for each correct answer)
1 True 1
2 (b) tuple 1
3 (d) {'B': None, 'R': None} 1
4 (b) False 1
5 (c) 6 1
6 (c) F=open ('Notes.dat', 'rb') 1
7 (a) UPDATE 1
8 (d) Delete From Student 1
9 (c) Statement 1 and Statement 4 1
10 (d) All of the above 1
11 (a) FileObject.seek(0,0) 1
12 (b) DESC 1
13 (c) Micro Wave 1
14 (d) 26 1
15 (d) LIKE 1
16 (a) tuple 1
17 (d) A is False but R is True. 1
18 (a) Both A and R are true and R is the correct explanation for A. 1
SECTION-B
19 x=int(input("Enter a no:-")) 2
if x%2==0:
for i in range(2*x):
print(i)
else:
print("#")
(½ mark for each correct correction made and underlined.)
20 Two points of differences between Hub and Switch are: 2
Hub Switch
Hub is an unintelligent device. Switch is an intelligent device
Hub broadcasts the data packets Switch directs the data packets to
to entire devices connected on the a specific computer or device.
network.
(OR)
( 1 mark for each correct point of difference)
Two points of differences between Hub and Switch are:
Star Topology Bus Topology
Central node dependency. No central node dependency.
If the host computer fails, the entire No host computer present.
communication will be blocked.
Expensive. Inexpensive.
(1 mark for each correct point of difference)
21 (a) 12+0+ @drWrbC 2
(1 mark for correct answer)

(b) New Delhi Beijing Washington DCOk LondonOk


(1 mark for correct answer)
22 The primary key is an attribute in a relation that uniquely identify a 2
record in a relation. A primary is required in a relation to avoid data
redundancy.
(1 mark for definition and 1 mark for significance)
23 (a) (i) GPRS-General Packet Radio Service 2
(ii) XML- eXtensible Markup Language
(1/2 mark for each correct answer)

(b) SMTP is used to send and receive email. It is sometimes paired with
IMAP or POP3, which handles the retrieval of messages, while SMTP
primarily sends messages to a server for forwarding.
(1 mark for correct answer)
24 0 @6 @7 @8 @9 @25 @11 @ 2
0@6@7@8@9@
(1 mark for each correct line of output)
(OR)
1lExAn7E9
(1 mark for 1lExA and 1 mark for n7E9)
25 CHAR- Holds upto 255 characters and allows a fixed length string. 2
(Appropriate example)
VARCHAR- Holds upto 65535 characters and allows a variable length
string. If you store characters greater than 55, then the data type will be
converted to TEXT type.
(Appropriate example)

(1 mark for difference and 1 mark for example.)


(OR)
CREATE-DDL
DELETE-DML
INSERT-DML
DROP-DDL
SECTION-C
26 (a) 1+2
name id class city
Hina 3 3 Delhi
Megha 4 3 Delhi
Gouri 6 3 Delhi
Hina 3 2 Delhi
Megha 4 2 Delhi
Gouri 6 2 Delhi
Hina 3 2 Delhi
Megha 4 2 Delhi
Gouri 6 2 Delhi

(1 mark for correct answer)

(b) (i) SUM(Qty)


31
(ii) MAX(DateOfOrder)
19-Jul-2021
(iii)
OrderId CustomerId DateOfOrder Price Qty
TQ006 81 17-Nov-2019 15000 12

(iv) DateOfOrder
03-Jan-2018

(1/2 mark for each correct answer)


27 def COUNT(): 3
f=open("d:\Story.txt","r")
he,she=0,0
s=f.read().split()
for i in s:
if i=='He':
he+=1
if i=='She':
she+=1
print("Total occurence of He=",he)
print("Total occurence of She=",she)
f.close()
(½ mark for correctly opening and closing the file
½ for read() and split()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
(OR)
def CountVowelConso()():
f=open("d:\Text.txt","r")
v,c=0,0
s=f.read()
for i in s:
if i.isalpha():
if i.lower() in 'aeiou':
v+=1
else:
c+=1
print("Total occurence of vowels=",v)
print("Total occurence of consonants=",c)
f.close()
(½ mark for correctly opening and closing the file
½ for read()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)
28 (a) (i) SELECT W_ID, FIRSTNAME, ADDRESS, CITY FROM 2+1
WORKERS WHERE CITY= „New York‟ ;
(ii) SELECT * FROM WORKERS ORDER BY LASTNAME ;
OR
SELECT * FROM WORKERS ORDER BY LASTNAME ASC ;
(iii) SELECT MIN(SALARY) FROM DESIG
GROUP BY DESIGNATION
HAVING DESIGNATION IN („Manager‟, „Clerk‟) ;
(iv) SELECT FIRSTNAME, SALARY
FROM WORKERS, DESIG
WHERE WORKERS.W_ID = DESIG.W_ID ;
(1/2 mark for each correct answer)

(b) SHOW DATABASES


29 def FIND(L): 3
MaxList=[]
for i in L:
MaxList.append(max(i))
return MaxList
L=[[8,11,10,12],[5,14,6,7],[2,4,5,19],[3,12,5,12]]
print(FIND(L))
(½ mark for correct function header
1 mark for correct loop
1 mark for correct append()
½ mark for return statement)
Note: Any other relevant and correct code may be marked
30 system=[] 3
def Push_element(comp):
if comp[3]>8:
L1=[comp[1],comp[2]]
system.append(L1)

def Pop_element ():


num=len(system)
while len(system)!=0:
dele=system.pop()
print(dele)
num=num-1
else:
print("Stack Empty")

(1.5 marks for correct push_element() and 1.5 marks for correct
pop_element())
OR

SCORE={"KAPIL":40, "SACHIN":55, "SAURAV":80, “RAHUL":35,


"YUVRAJ":110}

def PUSH(S,R):
S.append(R)

def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in SCORE:
if SCORE[k]>49:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
(1.5 marks for correct PUSH() and 1.5 marks for correct POP())

SECTION-D
31 i) 5
HR Business

Technology Law

ii) Switch/ Hub


iii) HR Center as it is having maximum computer.
iv) WAN as the distance is more.
v) Firewall

(1 mark for each correct answer)


32 (a) 150 @ 1 2+3
150 @ 15000
(1 mark for each correct line of output)

(b) (i) database=‟Performance‟


(ii) record=mycursor.fetchall()
(iii) mycursor.execute(“Select * from Student Where Grade=‟A‟ ”)
(1 mark for each correct answer)
OR
(a) #BSE *3132
(1 mark for #BSE * and 1 mark for 3132)

(b) (i) database=‟Certification‟


(ii) mycursor.fetchmany(3)
(iii) mycursor.rowcount
(1 mark for each correct answer)
33 The csv. writer() function returns a writer object that converts the user's 5
data into a delimited string.

import csv
def ADD():
f=open("Newspaper.csv","w",newline='')
obj=csv.writer(f)
Name=input("Enter name of the newspaper:")
N=int(input("Enter number of pages:"))
press=input("Enter press name:")
L=[Name,N,press]
obj.writerow(L)
f.close()

def SEARCH():
f=open("Newspaper.csv","r")
obj=csv.reader(f)
found=0
Nm=input("Enter the newspaper you want to search")
for i in obj:
if i[0]==Nm:
print(i)
found=1
if found==0:
print("No such newspaper found")
f.close()
ADD()
SEARCH()

(1 mark for writer object


½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and SEARCH()
½ mark for function call statements)
OR
CSV File Text File
The records are shown in a tabular Contents of the file are displayed
form. in text or may be in specific
format.
The extension of the file is .csv. The extension of the file is .txt or
.doc.

import csv
def ADD():
f=open("English.csv","w",newline='')
obj=csv.writer(f)
Cl=input("Enter Class:")
Se=int(input("Enter Section:"))
Ma=input("Enter Mark:")
L=[Cl, Se, Ma]
obj.writerow(L)
f.close()

def COUNT():
f=open("English.csv","r")
obj=csv.reader(f)
ctr=0
for i in obj:
if i[2]>=90:
ctr+=1
print("Total no of students securing >=90",ctr)
f.close()
ADD()
COUNT()

(1 mark for correct difference


½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and COUNT()
½ mark for function call statements)
SECTION-E
34 (i) StuID as it is the primary key in Student relation. 1+1+2
(1 mark for correct statement)
(ii) Degree=5, Cardinality=10
(1/2 mark for each for correct statement)

(iii) (a) INSERT INTO Student VALUES


(„CB06‟, „Navneeth‟, „Boy‟, 18, 80)
(b) UPDATE Student
SET AVgMark=AvgMark+3
WHERE Gender=‟Girl‟
(1 mark for each correct statement)
OR (Option for part iii only)
(iii) (a) DELETE FROM Student WHERE Age=17
(b) ALTER TABLE Student ADD (REMARKS VARCHAR(50))
(1 mark for each correct statement)
35 i) „w‟ or „a‟ 4
(1 mark for correct statement)

ii) reader(), close()


(1 mark for correct statement)

iii) Additem(101,‟Sofa‟)
readcontents()
(1 mark for each correct statement)
SAMPLE QUESTION PAPER - 3 (2022-23)

CLASS- XII
SUB: COMPUTER SCIENCE (083)

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 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.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False 1
“A new value can be reassigned to a String variable.”
2. What error occurs when you execute the following? 1
apple = mango
(a) SyntaxError b) NameError (c) ValueError (d) TypeError

3. Given the following dictionary 1


d = {“john”:40, “peter”:45}
Which statement to use to delete the entry for “john”?
a) d.delete(“john”:40) b) d.delete(“john”)
c) del d[“john”] d) del d(“john”:40)
4. What is the average value of the code that is executed below ? 1
>>>grade1,grade2 = 80,90
>>>average = grade1 + grade2 / 2
a) 85 b) 85.0 c) 125 d) 125.0
5. What will be the output of the following Python code? 1
print('abcdecdfcd'.partition('cd'))
(a) ('ab', 'cd', 'ecdfcd') (b) ('ab', 'cd', 'e‟,‟cd‟,‟f‟,‟cd')
(c) ['ab', 'cd', 'ecdfcd'] (d) ['ab', 'cd', 'e‟,‟cd‟,‟f‟,‟cd']
6. Which of the following not will open the file in write and read mode? 1
a. r+ b. a+ c. w+ d. wb

7. Which SQL keyword is used to put conditions on group? 1

a)ORDER BY b)WHERE c)HAVING d)BOTH b AND c

8. command removes an attribute from a Table 1


(a) Drop (b) Delete (c) Remove (d) None of the above

9. Which of the following statement(s) would give an error after executing the
following code? 1
a=' All and No one' #statement 1
a=a.strip('e') #statement 2
print(a) #statement 3
print(a.index('e')) #statement 4

(a) statement 1 (b) statement 2 (c) statement 3 (d) statement 4

10. Restrictions put on a column to accept a particular type of value is known as ___
1
(a) Domain b) constraints c) Integrity d) Consistency
11.The correct syntax of dump( ) is: 1
(a) pickle.dump(<fileobject>, <value> )
(b) pickle.dump(<value>,<fileobject>)
(c) dump(<fileobject>, <value> )
(d) dump(<value>,<fileobject>)
12.Fill in the blank: 1
In order to restrict the values of an attribute within a range, _________is to be used.
(a) Check (b) NULL (c) Default (d) NOT NULL
13.Fill in the blank: 1
_______ protocol is used to send emails
(a)FTP (b)SMTP (c)HTTP (d)TCP
14.What will the following expression be evaluated to in Python? 1
>>>7*(8/(5//2))
(a) 28 (b) 28.0 (c) 20 (d) 60
15.Which of the given symbol doesn‟t carry any meaning for a sql command 1
(a) _ (b) % (c) $ (d) *
16. Which method is used to retrieve all rows from the database 1
(a) fetchone() (b) fetchall() (c) fetchmany (d) fetchAll( )
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) :- A return statement returns a value as well as the control from a
function. Reasoning (R) :- It is compulsory for all functions to have a return statement.
1

18.Assertion (A) :- Opening a CSV file using the with clause automatically disconnects
the file handler when the scope gets over
Reasoning (R) :- close( ) is not required when file is open using with clause. 1
SECTION B
19. Rita has written a code to input a number and display the factorial. Her code is having
errors. Rewrite the correct code and underline the corrections made. 2
num=input('enter a number')
fact=0
fori in range(1,num):
fact=fact+i
print(„the factorial is‟ fact)
20. What is difference between star topology and bus topology of network? 2
OR
What is the importance of URL in networking? Name the three parts of URL.
21. (a) Given is a Python string declaration: 1
My_str= “Digital India”
Write the output of :
print(My_str[-4:])
(a) What will be the output of the following Python code 1
d = {"john":40, "peter":45}
print(list(d))

22. What is a key attribute. Explain any two keys through a Relation. 2

23. (a) Write the full forms of the following: 2


i) ARPANET ii) NIC
(b) Write about the importance of TCP.
24. What will be the output of the following code? 2
t = (100, 200 , 300 , [560, 780], 900)
t[3][-1] = [400 , 500]
print(t)
OR
What will be the output of the following code?
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][-2]
print(y)

25. Differentiate between char and varchardatatype in SQL with appropriate example. 2
OR
Categorize the following in accordance to their use with DDL and DML commands.
check , is null, sum, not null
SECTION C
26. (a) Consider the following tables – Student and Location: 1+2
Table :Student Table : LOCATION
LID LNAME LID LNAME
SID NAME 101 Delhi
S1 ANITA SINGH 102 Mumbai
ARORA
S2 Y.P. SINGH

What will be the output of the following statement?


SELECT * FROM STUDENT CROSS JOIN LOCATION;
(b) Write the output of the queries (i) to (iv) based on the table, SALES given below:

Table : SALES
SID NAME SALES DESIG
S1 ANITA SINGH ARORA 250000 D1
S2 Y.P. SINGH 1300000 D3
S3 TINA JAISWAL 1400000 D2
S4 GURDEEP SINGH 1250000 D2
S5 SIMI FAIZAL 1450000 D1
i) SELECT DESIG FROM SALES where name like „%H‟;
ii) SELECT DESIG, COUNT(*), MIN(SALES) FROM SALES
GROUP BY DESIG HAVING COUNT(DESIG)>1;
iii) SELECT NAME,SALES FROM SALES
WHERE SALES BETWEEN 100000 AND 1000000;
iv) SELECT DESIG, SUM(SALES) FROM SALES GROUP BY DESIG;

27. A text file named TOPIC.TXT contains some text, which needs to be displayed such
that every next character appears after a gap of a tab-space. Write a function definition
for TabDisplay() that would display the entire content of the file TOPIC.TXT in the
desired format.
3
Example:
If the file TOPIC.TXT has the following content stored in it:
MY FILE
The function TabDisplay() should display the following content:
M Y F I L E
OR
Write a method in python to read lines from a text file INDIA.TXT, to find and
display the occurrence of the word “INDIA” or “India”.
For example:If the content of the file is
INDIA is a famous country all over the world.
Geographically, India is located to the
south of Asia continent. India is a high
population country and well protected
from all directions naturally.
India is a famous country for
its great cultural and traditional
values all across the world.
___________________________________________
The output should be 4
28. (a)Write the outputs of the SQL queries (i) to (iii) based on the relations DEPT and
EMPLOYEE given below: 3
Table : DEPT
DCODE DEPARTMENT LOCATION
D01 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table : EMPLOYEE
ENO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 RymaSen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05

Note : DOJ refers to date of joining and DOB refers to date of Birth of employees.

i) SELECT COUNT(*),DCODE FROM EMPLOYEE GROUP BY DCODE


HAVING COUNT(*)>1;
ii) SELECT DISTINCT DEPARTMENT FROM DEPT;
iii) SELECT NAME,DEPARTMENT FROM EMPLOYEE E,DEPT D
WHERE E.DCODE=D.DCODE AND ENO<1003;
iv) SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;

(b) Show the structure of the Result table


29. Which will be the possible output of the following code. Also write the minimum and
maximum value that will be assigned to FROM and TO : 3
import random
AR = [20 , 30, 40, 50, 60, 70]
FROM = random.randrange(1,3)
TO =random.randrange(2,4)
for K in range(FROM , TO + 1):
print(AR[K] , end = '#')
(a) 30#40#50#60 (b) 30#40#50
(c) 30#50#70 (d) 20#30#40

30. Ram has created a dictionary containing names and marks as key value pairs of 6
students. Write a program, with separate user defined functions to perform the
following operations: 3
i) Push() - To Push the keys (name of the student) of the dictionary into a stack,
where the corresponding value (marks) is greater than 90.
ii) Pop() - To Pop the objects from the stack and display them. Also, display “Stack
Empty” when there are no elements in the stack and display the content of the stack.
For example: If the sample content of the dictionary is as follows:
R={"OM":96, "JAI":45, "BOB":99, "ALI":65, "ANU":95, "TOM":92}
The output from the program should be:
TOM ANU BOB OM
OR
Alfred has a list containing 10 integers. You need to help him create a program with
separate user defined functions to perform the following operations based on this list.
i) Traverse()- To traverse the content of the list and push the even numbers into a stack.
ii) Pop()- to pop and display the content of the stack.
For Example: If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12
SECTION D
31. A company ABC Enterprises has four blocks of buildings as shown:

B1 B2

B3
B4
Center to Center distance between blocks Number of computers in each block
B3 TO B1 50 M B1 150
B1 TO B2 60 M B2 15
B2 TO B4 25 M B3 15
B4 TO B3 170 M B4 25
B3 TO B2 125 M
B1 TO B4 90 M
Computers in each block are networked but blocks are not networked. The company has now
decided to connect the blocks also.
(i) Suggest the most appropriate topology for the connections between the blocks. 1
(ii) The company wants internet accessibility in all the blocks. The suitable and
cost-effective technology for that would be? 1
a. Satellite b. Lease line c. Telephone line d. Broadband
(iii) Which devices will you suggest for connecting all the computers with in each
of their blocks? 1
(iv) The company is planning to link its head office situated in New Delhi with the
offices in hilly areas. Suggest a way to connect it economically. 1
(v) Suggest the most appropriate location of the server, to get the best
connectivity for maximum number of computers. 1
32. (a) Write about any two functions of return keyword. 2
(b) The code given below inserts the following record in the table Employee:
ENo – integer
EName – string
Esalary – float
Note the following to establish connectivity between Python and MYSQL:
● Username is TECHIT
● Password is tech
● The table exists in a MYSQL database named Employee.
● The details (ENo, EName and Esalary) are to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to import the required module
Statement 2 – to create the connection object
Statement 3- to add the record permanently in the database

import _____________ as mysql #Statement 1


defsql_data():
con1=mysql.__________________________________ #Statement 2
mycursor= con1.cursor()
Eno=int(input("Enter Number :: "))
Ename=input("Enter name :: ")
Esalary=int(input("Enter salary :: "))
querry="insert into student values({},'{}',{},{})".format(ENo, EName ,Esalary)
mycursor.execute(querry)
______________________ # Statement 3
print("Data Added successfully")

OR
(a) Write about the mutability and immutability concept of Parameters.
(b) The code given below inserts the following record in the table Employee:
ENo – integer
EName – string
Esalary – float
Note the following to establish connectivity between Python and MYSQL:
• Username is TECHIT
• Password is tech
• The table exists in a MYSQL database named Employee.

Write the following missing statements to complete the code:


Statement 1 – to import the required module
Statement 2 – to create the connection object
Statement 3- to read the complete result of the query (records whose salary are greater
than 10000) into the object named data, from the table student in the database.
import __________ as mysql #Statement 1
defsql_data():
con1=mysql._______________ #Statement 2
mycursor= con1.cursor()
print("Employees with salary greater than 10000 are : ")
mycursor.execute("select * from Employee where Esalary> 10000")
data=__________________ #Statement 3
fori in data:
print(i)
print()

33. Write the characteristics of CSV files. 5

Write a Program in Python that defines and calls the following user defined functions:
i) APPEND() – To add two records of book to a CSV file „BOOK.csv‟. Each record
consists of a list with field elements as bookid, bname and price to store book id, book
name and book price respectively.
ii) DISP() – To count and display the number of records in the following format.
Books above price 500 :
Books with price equals to or less than 500:
OR
Give any one point of difference between a text file and a csv file. Write a Program in
Python that defines and calls the following user defined functions:
i) APPEND() – To add records of student to a CSV file „STUDENT.csv‟. Each record
consists of a dictionary with field elements as roll, name and stream to store roll no,
name and stream ( sc,com,hum) respectively.
ii) DISP()- To display the details of the students of „hum‟ stream.

SECTION E
34. Raina creates a table Item to maintain the Item details as Itemno, Iname, price and
quantity. After creation of the table, she has entered data. 1+1+2

Table: Item
Itemno Iname Price Quantity
101 Soap 50 100
102 Powder 100 50
103 Face cream 150 25
104 Pen 50 200
105 Soap box 20 100

(i) Identify the Candidate keys from the above table.


(ii) What is the degree and cardinality of the above table?
(iii) Write the statements to:
a. Display a report with item number, item name and total price.
(total price = price * quantity).
b. Display item table information in ascending order based upon item name.

OR (Option for part iii only)


(iii) Write the statements to:
a. Display the item information whose name starts with letter 's'.
b. Increase price value by 100.

35. Reshma is a programmer, who has recently been given a task to write a python code to
perform the following binary file operations with the help of two user defined
functions/modules:
a. AddStudents() to create a binary file called STUDENT.DAT containing student
information – roll number, name and percent (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who have a
percentage greater than 75. In case there is no student having percentage > 75 the
function displays an appropriate message. The function should also display the average
percent.
As an expert help Reshma complete the missing statements and other related queries
based on the following code.

import pickle
defAddStudents():
____________ #1
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent] ____________ #2
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
defGetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
____________ #3
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent = ",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("There is no student who has percentage more than 75")
average=Total/Countrec
print("average percent of class = ",average)

(i) Write the command to open the file “STUDENT.DAT. (#1) 1

(ii) Write the command to write the list L into the binary file, STUDENT.DAT.(#2) 1

(iii) Which command is used to read each record from the binary file STUDENT.DAT? (#3)

2
SAMPLE QUESTION PAPER (2022-23)
CLASS- XII
SUB :COMPUTER SCIENCE (083)
MARKING SCHEME - 3
1 True 1
2 b 1
3 c 1
4 d 1
5 a 1
6 d 1
7 c 1
8 a 1
9 d 1
10 b 1
11 a 1
12 a 1
13 b 1
14 b 1
15 c 1
16 b 1
17 C 1
18 a 1

num=int(input('enter a number'))
fact=1
for i in range(1,num):
fact=fact*i
print(‘the factorial is’ , fact)
19 (½ mark for each correct correction made and underlined.) 2
In star topology, nodes are connected to server individually
whereas in bus topology all nodes are connected to server
along a single length of cable.
OR
URL stands for Uniform Resource Locator. Each page that is
created for Web browsing is assigned a URL that effectively
serves as the page’s worldwide name or address. URL’s have
three parts: the protocol, the DNS name of the machine on
which the page is located and a local name uniquely indicating
the specific page(generally the filename).
20 ½ mark for URL and 1½ mark for its parts. 2
a) ‘ndia’
21 b) *‘john’,’peter’+ 2
1 mark for explaining key attribute
22 ½ mark for each example (2 keys) 2
a) Advance Research Project Agency Network
Network Interface card
(½ mark for every correct full form)
b) TCP breaks the message into packets.
23 (1 mark for correct answer) 2
(100, 200, 300, [560, [400, 500]], 900)
OR
24 14.0 2
1 mark for difference
1 mark for example
OR
DDl- check, not null
DML- is null,sum
25 ½ mark for each correct category 2
(a) 1 mark for correct output
SID NAME LID LNAME
S1 ANITA SINGH ARORA 101 Delhi (b) ½
S1 ANITA SINGH ARORA 102 Mumbai mark
S2 Y.P. SINGH for
101 Delhi
S2 Y.P. SINGH each
102 Mumbai
correc
t output
i) D3
D2
ii) DESIG, COUNT(*), MIN(SALES)
D1 2 250000
D2 2 1250000
iii) NAMESALES
ANITA SINGH ARORA 250000
iv) DESIG SUM(SALES)
D1 1700000
D3 1300000
26 D2 2650000 1+2
½ mark for opening file
½ mark for loop
1 mark for reading
½ mark for tab
27 ½ mark for output 3
a) ½ mark for each correct output
b) DESCRIBE Result
28 1 mark 3
(b) 30#40#50 1 mark
Min Max
FROM 1 2 ½ mark for each value
29 TO 2 3 ½ mark for each value
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90,
"TOM":82}
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in R:
if R[k]>=90:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
OR
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%2==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break

1 mark for correct PUSH operation


1 mark for correct POP operation
30 1 mark for correct function calls and displaying the output 3
i) Star topology
ii) Broadband
iii) Switch/Hub
iv) Radio waves
31 v) BLOCK B1

32 a) 2 marks for two points 2+3


b )#1 mysql.connector

#2
connect(host="localhost",user="TECHIT",password="tech
", database="Employee")

#3 con1.commit()

1 mark for each correct statement


OR
a) 2 marks for explanation
b) #1 mysql.connector

#2
connect(host="localhost",user="TECHIT",password
="tech", database="Employee")

#3 mycursor.fetchall()
1 mark for each correct statement
(1mark for charecteristics ½ mark for importing csv module 1
½ marks each for correct definition of APPEND() and DISP() ½
mark for function call statements )
OR
(1 mark for difference ½ mark for importing csv module 1 ½
marks each for correct definition of APPEND() and DISP() ½
33 mark for function call statements ) 3
i) Itemno, Iname
½ mark for each key
ii) Degree- 4, cardinality-5
½ mark for each value
iii) a. Select Itemno,Iname, price*Quantity as Totprice
from Item;

b. Select*from Item order by Iname;


1 mark for each correct query
OR 1
a. Select*from Item where name like ‘s%’; 1
b. Update Item set Price=Price+100; 2
34 1 mark for each correct query
a) F= open("STUDENT.DAT",'wb') 1
b) pickle.dump(L,F) 1
35 c) R = pickle.load(F) 2
Roll No.

SAMPLE QUESTION PAPER – 4 (2022-23)

 Please check that this question paper contains 15printed pages.


 Set number given on the right hand side of the question paper should be
written on the title page of the answer book by the candidate.
 Check that this question paper contains 35 questions.
 Write down the Serial Number of the question in the left side of the
margin before attempting it.
 15 minutes time has been allotted to read this question paper. The question
paper will be distributed 15 minutes prior to the commencement of the
examination. The students will read the question paper only and will not
write any answer on the answer script during this period.

CLASS- XII
SUB: COMPUTER SCIENCE(083)

Time Allowed: 3 Hours Maximum Marks: 70


General Instructions:

1. Thisquestionpapercontainsfivesections,SectionAtoE.
2. Allquestionsarecompulsory.
3. SectionAhave18questionscarrying01markeach.
4. SectionBhas07VeryShortAnswertypequestions carrying02markseach.
5. SectionChas05ShortAnswertypequestionscarrying03markseach.
6. SectionDhas03LongAnswertypequestionscarrying05markseach.
7. SectionEhas02questionscarrying04markseach.
8. AllprogrammingquestionsaretobeansweredusingPythonLanguageonly.

STD-XII/COMP.SC PAGE- 1
SECTION -A
1. StateTrueorFalse 1
“InPython, when the value of a variable changes, its id changes also”.
2. Whichofthefollowingisaninvalid identifierinPython? 1
(a) List (b) sum (c) MyData (d) True
3. Giventhefollowingdictionary 1
colors = {"Red":111, "Blue":333, "Green":555}

Whichstatementwill delete the element “Blue”:333 ?


a. clear colors(“Blue”)
b. clear colors(“Blue”:111)
c. del colors(“Blue”)
d. del colors[“Blue”]
4. Considerthegivenexpression: 1
not True or not False and not True
Whichofthefollowingwillbecorrectoutputifthegivenexpressionisevaluated?
(a) True
(b) False
(c) NONE
(d) NULL
5. Selectthecorrectoutputofthecode: 1
a='abc'
b='de'
c=a+b+b*2
print(c)

(a) „abcdededede‟
(b) „abcdedeabcdede‟
(c) 'abcdedede'
(d) „abcdede‟
6. Whichofthefollowingcan be used to read the next line from a
file object fobj? 1
(a)fobj.read(2) (b)fobj.readline()
(c)fobj.read() (d)fobj.readline(2)
7. Which of the following is not a valid DML command? 1
(a)delete (b) insert (c) drop (d)select
8. Whichofthefollowingcommandswilldeletea viewfromMYSQL
database? 1
(a) DELETEVIEW
(b) DROPVIEW
(c) REMOVEVIEW
(d) ERASE VIEW

STD-XII/COMP.SC PAGE- 2
9. Which of the following statement(s) are erroneous in the followingcode? 1
S="Python" # Statement 1
T=”Program” #Statement2
ST=2*S*T #Statement3
S[0]='@' #Statement4
S=S+"Thankyou" #Statement5

(a) Statement3
(b) Statement4
(c) Statement3 and 4
(d) Statement 3 and 5
10. is a key attribute, which is a Candidate key but not the Primary key. 1

(a) PrimaryKey
(b) ForeignKey
(c) CandidateKey
(d) Alternate Key
11. Which of the following module is to be imported to rename a file : 1
(a) pickle
(b) files
(c) dos
(d) os
12. Fill in the blank: 1
TheSELECTstatementwhencombinedwith clause,returns
records in sorted manner.

(a) Group by
(b) Sorted by
(c) Order by
(d) List by
13. Fillintheblank: 1
162.248.49.180 is an example of ____________.
(a)MAC address (b)IP address (c) Host address (d) a & b
14. WhatwillthefollowingexpressionbeevaluatedtoinPython? 1
print(12%5**3+(2*6)//4)
(a) 14.75 (b)14.0 (c)15.5 (d)15
15. Functions that do not explicitly return a value return the special object1
(a) pass
(b) void
(c) NULL
(d) None

16. ToestablishaconnectionbetweenPythonandSQLdatabase,connect()isused.
STD-XII/COMP.SC PAGE- 3
Whichof the followingargumentsmaynotnecessarily begiven
whilecallingconnect()?
1

(a) host
(b) database
(c) user
(d) password

Q17and18areASSERTIONANDREASONINGbasedquestions.Markthecorr
ectchoiceas

(a) BothAandR aretrueand Risthe correct explanation for A


(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTruebutRisFalse
(d) Aisfalse butRisTrue
17. Assertion(A):-Iftheargumentsinfunction call statementmatchthe 1
Numberandorderofargumentsasdefinedinthefunctiondefinition,
suchargumentsare called positionalarguments.
Reasoning(R):-Duringafunctioncall,theargumentlistpositional argument(s)
must occur after the default arguments.
18.
Assertion(A):CSV(CommaSeparatedValues)isafileformatfordatastoragewhi
ch Lookslikea text file. 1
Reason(R):Records of a CSV file can be read by using readline() and
readlines() functions.

SECTION-B

19. Rao has written a code to input a number and find out its square root. His
codeis having errors. Rewrite the correct code andunderlinethe
correctionsmade. 2

def Check():
n = int(input("Enter a number "))
for k in range (1,n//2)
if k*k = n:
print("Square root = ",k)
break
if k == n/2-1:
print("Not a perfect square „)

Check()

STD-XII/COMP.SC PAGE- 4
20. WritetwopointsofdifferencebetweenClient Side Script and Server Side Script.
2
OR
Writeone advantage and one disadvantage of Coaxial cable and Optical Fibre.
21.
(a) GivenisaPythonstringdeclaration: 1
str="This is a test string"
Writetheoutputof:print(str[-1:-9:-2])

(b) Writetheoutputofthecodegivenbelow: 1
dict = {"code": 111, "price": 100}
dict['name'] = 'AAA'
dict['price'] = 200
print(dict.values())

22. Explain Degree and Cardinality in the context of Relational Database


Management System. 2
23. (a) Writethefullformsofthefollowing: 2
(i) IMAP (ii)POP

(b) WhatistheuseofVoIP?

24. PredicttheoutputofthePythoncodegivenbelow: 2

data=["P",20,"R",10,"S",30]
times=0
alpha=""
add=0
for c in range(1,6,2):
times=times+c
alpha=alpha+data[c-1]+"S"
add=add+data[c]
print(times,add,alpha)

OR
PredicttheoutputofthePythoncodegivenbelow:
tuple1 = (77, 11, 55, 22, 44, 88)
list1 =list(tuple1)
M=max(list1)
m=min(list1)

STD-XII/COMP.SC PAGE- 5
fori in range(len(list1)):
if list1[i]==M:
k=i
if list1[i]==m:
n=i
list1[k], list1[n] = list1[n], list1[k]
tuple1 = tuple(list1)
print(tuple1)
25. Differentiate between Delete and Drop commands in SQL. 2
OR
Categorize the following commands as DDL or DML.
DELETE, INSERT, CREATE, SELECT

SECTION-C
26. (a) Considerthefollowingtables–EmpandDept: 1+2
Table :Emp
EmpCode Name Desig
E001 Amartya Mgr
E002 Kim Exec
E003 John Supv

Table :Dept
EmpCode Area
E001 Delhi
E002 Chandigarh
E001 Noida
Whatwillbetheoutputofthefollowingstatement?

SELECT*FROMEmpNATURALJOINDept;

(c) Write output of the following SQL commands.


Table :Schoolbus
Rtno Area_overed Capacity Noofstudents Distance Transporter Charges
1 Vasantkunj 100 120 10 Shivamtravels 100000
2 HauzKhas 80 80 10 Anand travels 85000
3 Pitampura 60 55 30 Anand travels 60000
4 Rohini 100 90 35 Anand travels 100000
5 Yamuna 50 60 20 Bhalla Co. 55000
Vihar

STD-XII/COMP.SC PAGE- 6
6 Krishna 70 80 30 Yadav Co. 80000
Nagar
7 Vasundhara 100 110 20 Yadav Co. 100000
8 PaschimVihar 40 40 20 Speed travels 55000
9 Saket 120 120 10 Speed travels 100000
10 JankPuri 100 100 20 Kisan Tours 95000

(i)select sum(distance) from Schoolbus where transporter= “ Yadav Co.”;

(ii) select min(Noofstudents) from Schoolbus;

(iii) selectavg(charges) from Schoolbus where transporter= “ Anand travels”;

(iv) select distinct transporter from Schoolbus;

27.WriteamethodCOUNTLINES()inPythontoreadlinesfromtextfile
„TESTFILE.TXT‟ and display the lines which are not ending with any
digit. 3
OR

Write a function Count() in Python, which should read a


textfile“MYTESTFILE.TXT” and then count and displaythe count of
occurrencesof the words “is” and “are” individually as independent words.
Example:

Ifthefilecontentisasfollows:

Todayisapleasantday.It mightrain today.


Itismentionedonweathersites.
Rainy days are enjoyable.
TheCount()functionshoulddisplaytheoutputas:
count of is : 3
count of are : 1

28. (a) Write the SQL queries (i) to (iii) based on the relations Employee and

STD-XII/COMP.SC PAGE- 7
Posting given below: 3
Employee
Empid Firstname Lastname Address City
010 Ravi Kumar Raj nagar GZB
105 Harry Waltor Gandhi nagar GZB
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends New Delhi
street
300 Robert Samuel 9 Fifth Cross Washington
335 Ritu Tondon Shastri Nagar GZB
400 Rachel Lee 121 Harrison New York
St.
441 Peter Thompson 11 Red Road Paris
Empsalary
Empid Salary Benefits Designation
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 salesman
(i) To show firstname, lastname, address and city of all employees living in
Paris.
(ii) To display the content of Employee table in descending order of
Firstname.
(iii) To display the firstname, lastname and total salary of all managers from
the tables Employee and Empsalary , where total salary is calculated as
salary+benefits.
(iv) To display the maximum salary among managers and clerks from the
table Empsalary.

(b) Writethecommandtoview alltablesin a database.

STD-XII/COMP.SC PAGE- 8
29. Writeafunction NEW_LIST(L),whereListhelistofintegerspassedasthatstores
all the 4 digits integers present inL. 3

Forexample:
IfLcontains[123,3454,0,87511,8612,5678,66]

TheNewListwillhave[3454,8612,5678]

30. A list contains following records of some books: 3


[Book_name, Subject,Price]

Write the following user defined functions to perform given operationsonthe


stack named„mybooks’:

(i) Push_element()-ToPushanobjectcontaining Book nameand Price of


books whose subject is “Comp Sc”tothestack
(j) Pop_element() - To Pop the objects from the stack anddisplay them.
Also, display “Stack Empty” when there are noelementsin the stack.
Forexample:

Ifthelistsofbookdetailsare:

[“C++”,“Comp Sc”,200]
[“Light”,“Physics”,350]
[“Plants”,”Biology”,200]
[“Python”,“Comp Sc”,300]

The stack should contain


[“Python”,300]
[“C++”,200]

The output should be:


[“Python”,300]
[“C++”,200]
StackEmpty
OR

Write a function in Python, Push(SItem) where , SItem is a


dictionarycontaining thedetailsof stationaryitems–{Sname:price}.
The function should push the names of those items in the stack whohaveprice
greaterthan75.Alsodisplaythecountofelementspushedintothe stack.

STD-XII/COMP.SC PAGE- 9
Forexample:
Ifthedictionarycontainsthefollowingdata:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

Thestackshouldcontain
Notebook
Pen
Theoutputshouldbe:
Thecountofelementsinthestackis2

SECTION-D

31. Mother-son Corporation has set up its new center at Jaipur, Rajasthan for its
office and web-based activities. It has 4 blocks ofbuildings.: 5

Distance between various buildings (in meter) are as follows: -


A to B 50
B to C 110
C to D 100
A to D 160
B to D 140
A to C 80
Number of computers installed at various buildings are as follows: -
A 50
B 100
C 135
D 90

As a network expert, provide the best possible answer for the following

STD-XII/COMP.SC PAGE- 10
queries: -
a) Suggest and draw the cable layout to efficiently connect various blocks of
the building within the Jaipur center for connecting the digital devices.
b) Suggest the placement of following devices in the network with
justification:
 Hub/Switch
 Repeater
c) Which kind of network (PAN/LAN/WAN) will be formed if the Jaipur
officeis connected to its head office in Mumbai?
Which fast and very effective wireless transmission medium should be
preferably be used to connect the head office at Mumbai with the center at
Jaipur?
d) Which fast and very effective wireless transmission medium should be
preferably be used to connect the head office at Mumbai with the center at
Jaipur?
e) Suggest the most suitable building to house the server with justification.
32. (a)Writetheoutputofthecode givenbelow: 2+3
p=5
def sum(q,r=2):
global p
p=r+q**2
print(p,end='#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)
(b)The code given below inserts the following record in the table
Student:
RollNo – integer
Name – string
Clas- integer
Marks–integer
NotethefollowingtoestablishconnectivitybetweenPythonandMYSQL:
 Usernameisroot
 Passwordistiger
 ThetableexistsinaMYSQLdatabasenamed school.
 The details (RollNo, Name, Clas andMarks) are to
beacceptedfromthe user.
STD-XII/COMP.SC PAGE- 11
Write the following missing statements to complete the code:
Statement 1– to formthecursor object
Statement2–toexecutethecommandthatinsertstherecordinthetableStudent.
Statement3-toaddtherecordpermanentlyinthedatabase

import mysql.connector as
mysqldefsql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycursor= #Statement
1rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
clas=int(input("Enter class :: "))
marks=int(input("Enter Marks :: "))
querry="insertintostudentvalues({},'{}',{},{})".format(rno,name,clas,marks)
#Statement2
#Statement3
print("Data Addedsuccessfully")

OR
(a) Predicttheoutputofthecodegivenbelow:
s="school2@com"
k=len(s)
m=""
fori in range(0,k):
if (s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
if i%2==0:
m=m+s[i].upper()
else:
m=m+s[i-1]
else:
m=m+'#'
s=m
print(s)
(b) The code given below reads the following record from the
tablenamed studentanddisplaysonly
thoserecordswhohavemarksgreaterthan75:
RollNo–integer
Name – string
Clas – integer
Marks–integer

STD-XII/COMP.SC PAGE- 12
NotethefollowingtoestablishconnectivitybetweenPythonandMYSQL:
 Usernameisroot
 Passwordistiger
 ThetableexistsinaMYSQLdatabasenamed school.

Writethefollowingmissingstatementstocompletethecode:
Statement1– to formthecursor object
Statement 2 – to execute the query that extracts records of those
studentswhosemarksaregreater than75.
Statement 3- to read the complete result of the query (records whose
marksaregreaterthan75)intotheobjectnameddata, fromthetablestudent
inthedatabase.
import mysql.connector as mysqldefsql_data():

con1=mysql.connect(host="localhost",user="root",password="tiger",database="school
")
mycursor= #Statement1
print("Studentswithmarksgreaterthan75are:")
#Statement2
data= #Statement3
foriindata:
print(i)
print()

33. Whatisthefunction of csv.reader object? 5


WriteaPrograminPythonthatdefinesandcallsthefollowinguserdefinedfunction
s:
(i) Write() – To accept and add data of a student to a CSV file„record.csv‟.
Each student record consists of a list with field elementsasroll, nameand
aggregatetostoreRoll Number,Student Nameand Aggregate
marksrespectively.
(ii) Count()–Tocountthenumberof student records with aggregate marks more
than 75, presentintheCSV filenamed„record.csv‟.
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following
userdefinedfunctions:
(i) add() – To accept and add data of a book to a CSVfile „book.csv‟.
Each record consists of a list with fieldelementsasbookid,
booknameandbookpriceto
storebookid,booknameandbookpricerespectively.

STD-XII/COMP.SC PAGE- 13
(ii) search()-Todisplaytherecordsof all books.

SECTION-E

34. NavdeepcreatesatableRESULT withasetof recordsto


maintainthemarksSecuredbystudentsinSem1,Sem2,Sem3andtheirdivision.Afterc
reationofthetable,hehasentereddataof7studentsin thetable. 4

Table:RESULT

ROLL_NOSNAMESEM1 SEM2 SEM3 DIVISION

101 KARAN 366 410 402 I


102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II
107 NEELAM 470 450 471 I

Basedonthedatagivenaboveanswerthefollowingquestions:

i. Identify the most appropriate column, which can be considered


asPrimarykey.
ii. Iftwocolumnsareaddedand2rowsaredeletedfromthetableresult,whatwillbe
thenewdegreeandcardinalityoftheabovetable?
iii. Writethestatementsto:
• Insertthefollowingrecordintothetable
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-
475,Div– I.
• IncreasetheSEM2marksofthestudentsby3%whosenamebeginsw
ith „N‟.
Or(OptionforPartiiionly)
iii. Writethestatementsto:
a. DeletetherecordofstudentssecuringIVdivision.
b. AddacolumnREMARKSinthetableRESULT
withdatatypeasvarcharwith50characters

STD-XII/COMP.SC PAGE- 14
35. Amit is a Python programmer. He has written a code and created
abinaryfilestu.datwithRoll,Name and Age of
students.Thefilecontains10records.Henowhastomodify the name of rollno 15
as “Arindam”. The updated record is then to bewritten in the file stu.dat. If
thestudent record is not found, an appropriate message should
bedisplayed.AsaPythonexpert,helphimtocompletethefollowingcodebasedonth
erequirement givenabove:
4

import________ # Statement 1
stu = [ ]
found = False
fin = _______________ # Statement 2
try:
while True:
rpos = fin.tell()
stu = __________ # Statement 3
ifstu[0] == 12:
stu[1] = “Arindam”
_____________ # Statement 4
pickle.dump(stu, fin)
found = True
except EOFError:
if found == False:
print(“No such record found”)
else:
print(“Record updated”)
fin.close()

(i)Which module should be imported in the program? (Statement 1)

(ii) Write the correct statement required to open the file stu.dat
(Statement 2)

(iii) Which statement should Amit write at Statement 3 to read the data
fromthe binary file stu.dat?

STD-XII/COMP.SC PAGE- 15
(iv) Which statement should Amit write to position the file pointer at
positionrpos in the file stu.dat (Statement 4)
******

STD-XII/COMP.SC PAGE- 16
SAMPLE QUESTION PAPER (2022-23)
CLASS- XII
SUB: COMPUTERSCIENCE(083)
MARKING SCHEME - 4
Time Allowed: 3 Hours Maximum Marks: 70
QST Value Points Marks
Allotted
N
NO
1 Ans.TRUE 1

2 Ans.(d) TRUE 1

3 Ans:(d)del colors[“Blue”] 1
4 Ans:(b)False 1
5 Ans:(c) „abcdedede‟ 1
6 Ans:(b)fobj.readline() 1
7 Ans (c) drop 1
8 Ans: (b) DROP VIEW 1
9 Ans:(c) - Statement3 and 4 1
10 Ans:(d)Alternate Key 1
11 Ans:(d)os 1
12 Ans:(c) Order by 1
13 Ans:(b)IP 1
14 Ans:(a)14.75 1
15 Ans:(d) None 1
16 Ans:(b)–Database 1
17 Ans:(c)A is True but R is False 1
18 Ans:(c) A is True but R is False 1
19 Ans: 2
def Check():
n = int(input("Enter a number "))
for k in range (1,n//2) : : missing
if k*k == n: = missing
print("Square root = ",k)
break
if k == n // 2-1: / missing
print("Not a perfect square ") “ missing

Check()

(½mark for each correct correction made and underlined.)


20 Ans: 2
Client Side Script Server Side Script
It is downloaded and run It runs at server end and result is send
at client end. to client end(browser)

It is browser dependent It is not browser dependent

Exp- JavaScript, VB Script Exp- ASP, JSP

(1mark for each correct point of difference)


OR
Ans:
Coaxial Cable –
Advantage – It provides a cheap means of transporting multi-channel television
signals around metropolitan areas.
Disadvantage – It is an expensive communication medium.
Optical Fibre –
Advantage – It is free from electrical noise and interference.
Disadvantage – It is costly and fragile.

(½mark for each correct advantage and ½ mark for each correct disadvantage.)

21 a. Ans: git 2
(1mark for the correct answer)

b. Ans:dict_values([111, 200, 'AAA'])


(1mark for the correct answer)
22 Ans: 2
Degree – Total number of columns / attributes in a relation.
Cardinality – Total number of rows in a relation.
(1 mark for correct definition of Degree, 1 mark for correct definition of
Cardinality)
23 a. Ans: 2
(i) IMAP:Internet Message AccessProtocol
(ii) POP:Post OfficeProtocol
(½ mark for every correct full form)
b. Ans:VoIP refers to a way to carry telephone calls over an IP data net work.
It offers a set of facilities to manage the delivery of voice information over
Internet in digital form.
(1mark for correct answer)
24 Ans: 9 60 PSRSSS 2
(1mark for 9 60 and 1 mark for PSRSSS)
OR
Ans: (77, 88, 55, 22, 44, 11)

(½ markfor each 2 correct digits of output ½ mark for parenthesis)


25 Ans: Delete command deletes records from a table where as Drop command 2
deletes an entire table / view.
Delete keeps the structure of the table intact but Drop deletes it.
Delete is a DML command but Drop is a DDL command.
(1 mark for each correct difference. Any 2 differences needed)
OR
DDL commands – DELETE, CREATE
DML commands – INSERT, SELECT
(½ mark for each correct answer)
26 Ans: 3
(a)
EmpCode Name Desig Area
E001 Amartya Mgr Delhi
E001 Amartya Mgr Noida
E002 Kim Exec Chandigarh
(1markforcorrect output)
(b)
(i) 50 (ii) 40 (iii) 72500

(iv) Shivam travels


Anand travels
Bhalla Co.
Yadav Co.
Speed travels
Kisan Tours
(1/2 mark for each correct answer)
27 Ans: 3
defCOUNTLINES():
file=open('TESTFILE.TXT','r')
lines=file.readlines()
count=0
forwinlines:
if (w[-1] not in '0123456789':
count=count+1
print("Thenumberoflines= ",count)
file.close()
COUNTLINES()
(½mark for correctly opening and closing the file
½for read lines()
½mark for correct loop
½for correct if statement
½mark for correctly incrementing count
½mark for displaying the correct output)
OR
Ans:
defCount():
file=open('MYTESTFILE.TXT','r')
str=file.read()
countis=0
countare=0
words = str.split()
for w in words :
ifw==‟is':
countis = countis + 1
if w==‟are‟:
countare=countare+1
print ("count of is : ", countis)
print (“count of are : ", countare)
file.close()
(½mark for correctly opening and closing the file
½for split()
½mark for correct loop
½for correct if statements
½mark for correctly incrementing counts
½mark for displaying the correct output)
Note: Any other relevant and correct code may be marked
28 Ans. (a) 2+1
(i) select Firstname, Lastname, Address, City from Employee where City =
„Paris‟;
(ii) Select Firstname, Lastname, Salary+Benefits from Employee, Empsalary
Where Employee.Empid = Empsalary.Empid;
(iii) Select Max(Salary) from Empsalary where Designation = „Manager‟ or
Designation = „Clerk‟
(1 mark for each correct answer)
Ans: (b)
SHOWTABLES;
(1markforcorrectanswer)

29 Ans: 3

defNEW_LIST(L):
NewList=[]
for i in L:
ifi>=1000 and i<=9999:
NewList.append(i)
returnNewList
(½ mark for correct function header
1mark for correctloop
1mark for correct if statement
½markforreturnstatement)
Note: Any other relevant and correct code may be marked
30 status=[] 3
def Push_element(book):
ifbook[1]=="Comp Sc":
L1=[cust[0],cust[2]]mybooks.append(L1)

def Pop_element ():num=len(mybooks)


while
len(mybooks)!=0:dele=mybooks.pop()print(d
ele)
num=num-1
else:
print("StackEmpty")
(1.5 marks for correct push_element() and 1.5 marks for
correctpop_element())
OR
stackItem=[]
def Push(SItem):
count=0
forkinSItem:
if
(SItem[k]>=75):stackItem.append(k)count=cou
nt+1
print("Thecountofelementsinthestack
is:",count)

(1 mark for correct function header1mark


for correctloop
½markforcorrectIfstatement
½mark forcorrectdisplayof count)
Note: Any other relevant and correct code may be marked
31 Ans. 4
a. Bus network (A to B, A to C, C to D)
b. Hub/Swich – in each building
c. Wan
d. Building C, as maximum number of computers are there.
(1 mark for each correct answer)

32 a. Ans: 6
Output:
105#6#
(1 markfor105#and1markfor6#)
b. Ans:

Ans:
Statement1:
con1.cursor()

Statement 2:mycursor.execute(querry)

Statement3:
con1.commit()

(1markforeachcorrectanswer)
OR
a. Ans:
SsHhOo##CcM

(1markforfirst5characters,1markfornext6characters)

b. Ans:
Statement1:
con1.cursor()
Statement2:
mycursor.execute("select*fromstudentwhereMarks>75")
Statement3:

mycursor.fetchall()
(1markforeachcorrectstatement)
33 Ans: 2
The csv.reader object reads data from a csv file on storage disk, removes the
delimitation and loads the data into a Python iterator wherefrom the data
can be fetched row by row.

Program:
import csv
defWrite():
fout=open("record.csv","a",newline="\n")wr=csv.writer(fout)
roll=int(input("EnterRoll::"))
name=input("EnterName::")
aggregate=int(input("EnterAggregate::"))
lst=[roll,name,aggregate]---------1/2mark
wr.writerow(lst) ---------1/2 markfout.close()

defCount():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
ctr=0
for i in data:
if [2]>75:
ctr = ctr+1
print(ctr)
fin.close()

Write()
Count()
(1mark for correct definition of csv.reader()
½mark for importing csv module
1 ½marks each for correct definition of Write()and Count()
½mark for function call statements)
OR

Ans:
Differencebetweenbinaryfileandcsvfile:
(Any1differencemaybegiven)
Binaryfile:
 Extensionis.dat
 Nothumanreadable
 Storesdataintheformof0sand1s
CSVfile
 Extensionis.csv
 Humanreadable
 Storesdatalikeatextfile
Program:
importcsv
defadd():
fout=open("book.csv","a",newline='')
wr=csv.writer(fout)
bid=int(input("Enter Book Id::"))
bname=input("Enter Book name :: ")
bprice=int(input("Enter Book price :: "))FD=[bid,bname,bprice] ---------
1/2mark
wr.writerow(FD)---------1/2mark
fout.close()
defsearch():
fin=open("book.csv","r",newline='')
data=csv.reader(fin)
print("The Details are")
foriindata:
print(i)
fin.close()
add()
search()
(1mark for difference
½markfor importingcsvmodule
1½markseachforcorrectdefinition of add()and search()
½markfor function call statements)
34 2
Ans:
(i) ROLL_NO

(1markforcorrectanswer)
(ii)
NewDegree:8
NewCardinality:5
(1/2markforcorrectdegreeand½markforcorrectcardinality)

Ans:
a. INSERTINTORESULTVALUES(108,„Aadit‟,470,444,475,„I‟);
b. UPDATERESULTSETSEM2=SEM2+(SEM2*0.03)WHERESNAMELIKE
“N%”;

(1markforeachcorrectstatement)

OR
Ans:
a. DELETEFROMRESULTWHEREDIV=‟IV‟;
b. ALTERTABLERESULTADD(REMARKSVARCHAR(50));
(1markforeachcorrectstatement)

35 (i) Ans:pickle 2
(1markforcorrectmodule)
(ii) Ans: fout=open(„stu.dat‟, „wb+‟)
(1markforcorrectstatement)
(iii) Ans:Statement3:pickle.load(fin)
(1markforcorrectstatement)
(iv) fin.seek(rpos)
(1markforcorrectstatement)
SAMPLE QUESTION PAPER – 5 (2022-23)
CLASS- XII
SUB : COMPUTER SC(083)
Time Allowed: 3 Hours Maximum Marks :70

General Instructions :
1. Thisquestionpapercontainsfivesections,SectionAtoE.
2. Allquestionsarecompulsory.
3. SectionAhave18questionscarrying01markeach.
4. SectionBhas07VeryShortAnswertypequestionscarrying02markseach.
5. SectionChas05ShortAnswertypequestionscarrying03markseach.
6. SectionDhas03LongAnswertypequestionscarrying05markseach.
7. SectionEhas02questionscarrying04markseach.Oneinternalchoiceisgivenin
Q35against partc only.
8. AllprogrammingquestionsaretobeansweredusingPythonLanguageonly.

SECTION–A

1. Find the valid identifier from the following. 1


a) Tax+Payer b) 21st c) _tax d) for
2. WhichofthefollowingisavaliddatatypeinPython? 1
(a)number (b)None (c) Decimal (d) Character

3. Giventhefollowingdictionaries 1

dict_exam={"Exam":"SSCE",
"Year":2023}dict_result={"Total":600,"Pass_Marks":198}

Whichstatementwillmergethecontentsofbothdictionaries?
a. dict_exam.update(dict_result)
b. dict_exam+dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)

CS SP - XII / 2022-23 Page 1 of 9


4. Considerthegivenexpression: 1
not True or False and False
Whichofthefollowingwillbecorrectoutputifthegivenexpressionisevaluated?

(a) True
(b) False
(c) NONE
(d) NULL

5. Selectthecorrectoutputofthecode: 1
a = "Happy 2023 New Year"
a = a.split('2')
b = a[0] + a[1]+ a[2]
print(b)

(a) Happy 03 New Year (b) Happy 2 0 3 New Year


(b) 0 3 New Year (d) Happy New Year
6. Whichofthefollowingmodeinfileopeningstatementcreates a new file ? 1

(a) w+(b) r+ (c) r(d)Noneof the above

7 Which of the following is NOT a DML command? 1


a) SELECT b) DELETE c) UPDATE d) DROP

8 1
Which command displays name of all the databases present in RDBMS.
(a)SHOW ALL;(b) SHOW DATABASES;
(c) SHOW DATABASE;(d)VIEW DATABASE;

9 Whichofthefollowingstatement(s)wouldgiveanerrorafterexecutingthe 1
followingcode?
S="XII CBSE"
print(S) #Statement1
S="Bye Bye" #Statement2
S[0]='*' #Statement3
S=S+"Thankyou" #Statement4

(a) Statement1 (b) Statement 2


(c)Statement3 (d)Statement 4

10 ________________ is not a category of SQL command. 1


a) TCL b) SCL c) DCL d) DDL

CS SP - XII / 2022-23 Page 2 of 9


11 The load( ) function is available under ___________ module. 1
a) CSV b) pickle c)Text d)binary

12 Which SQL function is used to count the number of rows in a SQL query? 1
a)COUNT() b)NUMBER() c)SUM() d)COUNT(*)

13 The arrangement of computers in a network is called _____________ 1

(a) Topology (b) Router (c) Protocol (d) Network


14 WhatwillthefollowingexpressionbeevaluatedtoinPython? 1
print(15.0//4+(8+3.0))

(a)14.75 (b)14.0 (c)15 (d)15.5

15 Which of the following is not a DDL command? 1


a) UPDATE b) TRUNCATE c) ALTER d) None of the Mentioned

16 To run an SQL query from within Python, you may use <cursor>. 1
_________method().
(a) query() (b) execute()
(c) run() (d) All of these

Q17and18areASSERTIONANDREASONINGbasedquestions.Markthecorrectchoiceas
(a) BothAandRaretrueandRisthecorrectexplanationforA
(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTruebutRisFalse
(d) Aisfalse butRisTrue
17 Assertion(A):-Iftheargumentsinfunctioncallstatementmatcheswith the 1
numberandorderofargumentsasdefinedinthefunctiondefinition,suchargumentsare
called positionalarguments.
Reasoning(R):-
Duringafunctioncall,theargumentlistfirstcontainsdefaultargument(s)followedbyp
ositional argument(s).
18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage 1
which looks like a text file.
Reason (R): The information is organized with one record on each line and each
field is separated by comma.

CS SP - XII / 2022-23 Page 3 of 9


SECTION - B

19 Rabi haswrittenacodetoinputanumberandcheckwhetheritisevenor odd. His code 2


is having errors. Rewrite the correct code and underline thecorrectionsmade.
def checkeven()
no=input(„Enter a number‟)
if no % 2 = 0:
print(„The number is even‟)
else:
Print(„The number is odd)
20 WritetwopointsofdifferencebetweenRouterandSwitch. 2
OR
Differentiate between Hacking and Cracking.
21 (a) GivenisaPythonstringdeclaration: 1
str = "My School@2022"
Writetheoutputof:print(str[-5::])
(b) Writetheoutputofthecodegivenbelow: 1
my_dict = {'name': 'Raj', 'mark': 99}
my_dict['mark'] = 75
my_dict['class'] = "XII"
print(my_dict.values())
22 What is the difference between CHAR & VARCHAR in SQL? 2
23 (a) Writethefullformsofthefollowing: 1
(i) SMTP (ii)WiFi
(b) WhatistheuseofBridge in a Network? 1
24 PredicttheoutputofthePythoncodegivenbelow: 2
def func(s):
x=[ ]
for i in range(len(s)):
a=s[i]
b=a.upper()
if a not in x and b not in x:
if a>'p':
x.append(a.upper())
else:
x.append(a)
return x
print(func('davschool'))
OR
PredicttheoutputofthePythoncodegivenbelow:
tup = (10,11,20,25,30,39,78)
li =list(tup)
new_li = []
for i in li:
if i%5==0:
new_li.append(i)
nt = tuple(new_li)
print(nt)

CS SP - XII / 2022-23 Page 4 of 9


25 What is a constraint? 2
Give at least two examples for the same.
OR
Categorize the following commands as DDL or DML:
DELETE, DROP, SELECT, CREATE
SECTION - C
26 (a) Write the difference between DROP TABLE and DROP VIEW. 1+2
(b) Write the outputs of the SQL queries (i) to (iv) based on the table given below:

(i) SELECT DISTINCT ANO FROM TRANSACT ;


(ii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT
GROUP BY ANO HAVING COUNT(*)> 1;
(iii) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT
WHERE DOT <= '2017-06-01';
(iv) SELECT TYPE, COUNT(*) FROM TRANSACT GROUP BY TYPE;

27 Write a methodDISPLAY( ) in Python to read lines from a text file DIARY.TXT, and 3
displaythose lines, which are starting with an alphabet ‘T’.
OR
Write a method in python to read from a text file INDIA.TXT, to find and
display the occurrence of the word “is”.
For example:
If the content of the file is
“India is the fastest growing economy. India is looking for more investments
around the globe. The whole world is looking at India as a great market. Most of
the Indians can foresee the heights that India is capable of reaching.”
The output should be 4
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the table given below: 2+1
Table: SOFTDRINK
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20.00 120
102 Apple Drink 18.00 120
103 Nature Nectar 15.00 115
104 Green Mango 15.00 140
105 Aam Panna 20.00 135
106 Mango Juice Bahaar 12.00 150

CS SP - XII / 2022-23 Page 5 of 9


Table: LOCATION
DRINKCODE MPLACE
103 MUMBAI
102 NEW DELHI
105 HYDERABAD
104 MUMBAI
101 KOLKATA
106 NEW DELHI
(i) SELECT * FROM SOFTDRINK WHERE PRICE>15.00;
(ii) SELECT DRINKCODE, PRICE FROM SOFTDRINK WHERE DNAME LIKE ’%r’;
(iii) SELECT DRINKCODE, DNAME FROM SOFTDRINK
WHERE CALORIES BETWEEN110 AND 130;
(iv) SELECT S.DRINKCODE, MPLACE
FROM SOFTDRINK S,LOCATION L
WHERE S.DRINKCODE = L.DRINKCODE;
(b) Write MySql command that will be used to open an already existing
database “CONTACTS”.
29 WriteafunctionCOPY_INDEX(Li),whereLiisthelistofelementspassedas 3
argumenttothefunction.ThefunctionreturnsanotherlistnamedLi_in that stores the
indices of all Positive Elements of Li.

Forexample:
IfLicontains[21,4, -7,11, -97,56]

TheLi_inwillreturn-[0,1,3,5]
30 Write a function in Python PUSH_7(Arr), where Arr is a list of numbers. From 3
this list push all numbers divisible by 7 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 POP (Names) method in python (where Names is a list of names), to
remove the names by considering them to perform Pop operations of Stack.

SECTION - D

31 Hi Speed Technologies Ltd is a Delhi based organization which is expanding its


office setup to Chandigarh. At Chandigarh office campus, they are planning to 5
have 3 different blocks for HR, Accounts and Logistics related work. Each block
has number of computers, which are required to be connected in a network for
communication, data and resource sharing.

As a network consultant, you have to suggest the best network related solutions
for them for issues/problems raised in (i) to (v), keeping in mind the distances
between various blocks/locations and other given parameters.

CS SP - XII / 2022-23 Page 6 of 9


DELHI CHANDIGARH OFFICE

HR BLOCK ACCOUNTS
HEAD OFFICE
BLOCK

LOGISTIC
BLOCK

Shortest distances between various blocks/locations:

Number of Computers installed at various blocks are as follows:

(i) Suggest the most appropriate block/location to house the SERVER in the
CHANDIGARH Office (out of the 3 Blocks) to get the best and effective
connectivity. Justify your answer.

(ii) Suggest the best wired medium and draw the cable layout (Block to Block) to
efficiently connect various Blocks within the CHANDIGARH office compound.

(iii) Suggest a device/software and its placement that would provide data security
for the entire network of CHANDIGARH office.

(iv) Suggest network type out of the following kind of network for connecting
Delhi office with Chandigarh Office.
(a) PAN (b) WAN (c) MAN (d) LAN

(v) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
 Gateway
 Modem
 Switch

CS SP - XII / 2022-23 Page 7 of 9


32 (a) Rewrite the following code in python after removing all syntax error(s). Underline 2+3
each correction done in the code.

250 = Number
WHILE Number<=1000:
if Number=>750
print (Number)
Number=Number+100
else
print( Number*2)
Number=Number+50

(b) What are the possible outcome(s) executed from the following code? Also specify
the maximum and minimum values that can be assigned to variable PICKER.
import random
PICKER = random.randint (0, 3)
COLOR = ["BLUE", "PINK", "GREEN", "RED"]
for I in COLOR :
for J in range (1, PICKER):
print (I, end = " ")
print ()
(i) (ii) (iii) (iv)
BLUE BLUE PINK BLUEBLUE
PINK BLUEPINK PINKGREEN PINKPINK
GREEN BLUEPINKGREEN GREENRED GREENGREEN
RED BLUEPINKGREENRED REDRED

33 What is with statement in Python? 5


WriteaPrograminPythonthatdefinesandcallsthefollowinguserdefinedfunctions:

(i) ADDNEW() – To accept and add data of an student to a CSV


file„sturec.csv‟. Each record consists of a list of field namesasroll,
nameandmarktostorestudentroll,student nameandstudent
markrespectively.
(ii) COUNTSTU()–Tocountthe
totalnumberofrecordspresentintheCSVfilenamed„sturec.csv‟.

OR
Give any one point of difference between a binary file and a csv file.

Write a Program in Python that defines and calls the following user defined
functions:
a) pr_add() – To accept and add data of a product to a CSV file „pdata.csv‟. Each
record consists of a list with field elements as pid, pname and pprice to store
product id, product name and product price respectively.

b) pr_search()- To display the records of the product whose price is less than
500.

CS SP - XII / 2022-23 Page 8 of 9


SECTION - E
34 An Organisation decided to maintain a database for their Employees using SQL 4
to store the data. As a Head of the organisation, Ashok has decided that:
Name of the database – Organisation Name of the table – EMPLOYEE
The attributes of table EMPLOYEE are as follows:
ECODE – Numeric
NAME – Character of size 30
DESIGN – Character of size 20
SGRADE – character of size 3
DOJ – Date
Table: EMPLOYEE

a) Identify the attribute best suitable to be declared as a primary key.


b) Insert the following data into the attributes ECODE, NAME, DESIG,
SGRADE and DOJ respectively in the given table EMPLOYEE.
ECODE=109, NAME= “Abhishek Hota”, DESIGN=”MANAGER”,
SGRADE=”S01” and DOJ=”05-Jan-2020”.
c) Ashok wants to modify the data inside the table EMPLOYEE i.e. the
name “John Ken” with “Rashmi Arora” .Which command will he use to
change the name whose ECODE is 103.
d) Now Ashok wants to add new attribute i.e. ADDRESS in table
EMPLOYEE. Write a query to add this new attribute.

35 Amit Kumar of class 12 is writing a program to store roman numbers and find 4
their equivalents using a dictionary. He has written the following code. As a
programmer, help him to successfully execute the given task.
import __________ #Line 1
numericals = ,1: ‘I’, 4 : ‘IV’, 5: ‘V’ , 9: ‘IX’, 10:’X’, 40:’XL’,50:’L’,
90:’XC’, 100:’C’,400:’CD’,500:’D’,900:’CM’,1000:’M’-
file1 = open(“roman.log”,”_______”) #Line 2
pickle.dump(numerals,file1)
file1.close()
file2 = open(“roman.log”,’________”) #Line 3
num = pickle.load(file2)
file2.__________ #Line 4
n=0
while n!=-1:
print(“Enter 1,4,5,9,10,40,50,90,100,400,500,900,1000:”)
print(“or enter -1 to exit”)
n = int(input(“Enter numbers”))
if n!= -1:
CS SP - XII / 2022-23 Page 9 of 9
print(“Equivalent roman number of this numeral is:”,num*n+)
else:
print(“Thank You”)
(a) Name the module he should import in Line 1.
(b) In which mode, Amit should open the file to add data into the file in Line #2
(c) Fill in the blank in Line 3 to read the data from a binary file.
(d) Fill in the blank in Line 4 to close the file.

*****

CS SP - XII / 2022-23 Page 10 of 9


SAMPLE QUESTION PAPER
Computer Science(083)CLASS :XII
MARKING SCHEME - 5
Q Marks
Value Points
NO Allotted

1 c) _tax 1

2 (b)None 1

(a) dict_exam.update(dict_result)
3 1

4 (b)False 1

5 (a) Happy 03 New Year 1

6 (a) w+ 1

7 d) DROP 1

8 (b) SHOW DATABASES; 1

9 (c)Statement3 1

10 b) SCL 1

11 b) pickle 1

12 d) COUNT(*) 1

13 (a) Topology 1

14 (b)14.0 1

15 b) TRUNCATE 1

16 (b) execute() 1

17 (c)AisTruebutRisFalse 1

18 (a)BothAandRaretrueandRisthecorrectexplanationforA 1
Q Marks
Value Points
NO Allotted
19 def checkeven(): 2
no=int(input(„Enter a number‟))
if no % 2 ==0:
print(„The number is even‟)
else:
print(„The number is odd‟)
(½markforeachcorrect correctionmadeandunderlined.)
20 Router : 2
The main objective of router is to connect various networks simultaneously.
Router is used by LAN as well as MAN.
Switch:
The main objective of switch is to connect various devices simultaneously.
Switch is used by only LAN.
(1markforeachcorrectpointofdifference)
OR
Hacking and Cracking both is technical term, where “Hacking is The process
of attempting to gain or successfully gaining, unauthorized access to
computer resource.”
Whereas “Cracking is the act of breaking into a computer system, often on a
network maliciously, for personal gain.”
(1markforeachcorrectpointofdifference
21 (a) @2022 1
(b) dict_values(['Raj', 75, 'XII']) 1
(1markforeachcorrectanswer)
22 CHAR and VARCHAR are both ASCII character data types and almost same but 1
they are different at the stage of storing and retrieving the data from the
database. Following are some important differences between CHAR and
VARCHAR in MySQL
1
CHAR Data Type VARCHAR Data Type

Its full name is CHARACTER Its full name is VARIABLE CHARACTER

It stores values in fixed lengths and VARCHAR stores values in variable


are padded with space characters length along with 1-byte or 2-byte
to match the specified length length prefix and are not padded with
any characters
(1markforeachcorrectpoint of difference)
23 (a) SMTP – Simple Mail Transfer Protocol 1
WiFi – Wireless Fidelity
(½markforeachcorrectfullform)
(b) Bridges are used to divide large busy networks into multiple smaller and
interconnected networks to improve performance. Bridges are also used to connect
a LAN segment through a synchronous modem relation to another LAN segment at a 1
remote area.
(1markforcorrectanswer)
24 ['d', 'a', 'V', 'S', 'c', 'h', 'o', 'l'] 2
(10, 20, 25, 30)
(1markfor each correct output)
25 Constraint can be used to specify the limit on the data type of table. 2
Constraint can be specified while creating or altering the table statement.
Examples:NOT NULL, CHECK, DEFAULT, UNIQUE, PRIMARY KEY, FOREIGN KEY.
(Any two can be awarded suitably)
OR
DDL- DROP, CREATE
DML – DELETE, SELECT
(½ mark for each correct categorization)

26 (a) DROP TABLE command deletes the definition of the table as well as the 1+2
data of table. If the table is dropped, you cannot access it. While DROP VIEW
command only deletes the definition of view. Dropping a view does not affect
the base tables, i.e. no loss of data is there in DROP VIEW.

(1 mark for correct answer)


(b) OUTPUT
i)DISTINCT ANO
101
103
102
ii) ANOCOUNT(*)MIN(AMOUNT)
101 2 2500
103 2 1000
iii) COUNT(*)SUM(AMOUNT)
2 5000
iv) TYPECOUNT(*)
Withdraw 2
Deposit 3
(½ mark for each correct output)
27 def DISPLAY(): 3
file=open('DIARY.TXT','r')
line=file.readline()
while line:
if line[0]=='T' :
print( line)
line=file.readline()
file.close()
½markforcorrectlyopening
½ mark forreadline()
½markforcorrectloop
½forcorrectifstatement
½markforcorrectlydisplaying line
½markforclosingthefile
OR
def display():
c=0
file=open('INDIA.TXT','r')
lines = file.read()
words = lines.split()
for w in words:
if w=="is":
c=c+1

print (c)
file.close()
(½markforcorrectlyopening and closingthefile
½ mark forread() and split()
½markforcorrectloop
½forcorrectifstatement
½markforcounting
½markfor displaying c)
28 2+1
a) OUTPUT
i)
DRINKCODE DNAME PRICE CALORIES
101 Lime and Lemon 20.00 120
102 Apple Drink 18.00 120
105 Aam Panna 20.00 135
ii)
DRINKCODE PRICE
103 15.00
106 12.00
iii)
DRINKCODE DNAME
101 Lime and Lemon
102 Apple Drink
103 Nature Nectar
iv)
DRINKCODE MPLACE
101 KOLKATA
102 NEW DELHI
103 MUMBAI
104 MUMBAI
105 HYDERABAD
106 NEW DELHI
(1/2 mark for each correct output)

b) USE CONTACTS;
(1markforcorrectanswer)
29 def COPY_INDEX(Li): 3
Li_in = [ ]
for i in range(len(Li)):
if Li[i]>=0:
Li_in.append(i)
returnLi_in

(½ mark for correct function header


1mark for correctloop
1mark forcorrectifstatement
½markforreturnstatement)
Note:Anyotherrelevantandcorrectcodemaybemarked
30 def PUSH_7(Arr): 3
s=[ ]
for x in range(0,len(Arr)):
if Arr[x]%7==0:
s.append(Arr[x])
if len(s)==0:
print("Empty Stack")
else:
print(s)
OR

def pop(Names):
if Names == []:
print('Stack is empty!')
else:
print('Deleted elementis',Names.pop())
1 mark for correct function header
1mark for correctloop
½markforcorrectIfstatement
½mark forcorrectdisplay
31 (i) HR Block - Because it has maximum number of computers. 5
(ii)

(iii) Firewall - Placed with the server at the HR Block


(iv) WAN
(v) Switch
32 (a) 2+3
Number = 250
while Number<=1000:
if Number>=750:
print (Number)
Number = Number+100
else:
print (Number*2)
Number = Number+50
½ mark for each correction

(b) option (i)


PICKER max. value = 3, min. value = 0
1mark for correctoption
1/2mark for max. value
1/2mark for min. value
33 with statement in Python is used in to simplify the management of common 5
resources like file streams. It make the code cleaner and much more readable.
For e.g. there is no need to call file.close() when using with statement.

import csv
def ADDNEW ():
fout=open("sturec.csv","a",newline="\n")
wr=csv.writer(fout)
roll=int(input("Enter Student Roll- "))
name=input("Enter name- ")
mark=int(input("Enter student mark- "))
s=[roll,name,mark]
wr.writerow(s)
fout.close()

def COUNTSTU():
fin=open("sturec.csv","r",newline="\n")
data=csv.reader(fin)
s=list(data)
print(len(s))
fin.close()

ADDNEW()
COUNTSTU()

1 mark for writingwith statement


½ mark for importing csv module
1 ½ marks each for correct definition of ADDNEW() and COUNTSTU()
½ mark for function call statements
OR
Difference between binary file and csv file: (Any one difference may be given)
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

import csv
def pr_add():
fout=open("pdata.csv","a",newline='\n')
wr=csv.writer(fout)
pid=int(input("Enter Product Id - "))
pname=input("Enter Product name - ")
pprice=int(input("Enter product price - "))
P=[pid,pname,pprice]
wr.writerow(P)
fout.close()
def pr_search():
fin=open("pdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])<500:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()

pr_add()
print("Now displaying")
pr_search()
1 mark for difference
½ mark for importing csv module
1 ½ marks each for correct definition of pr_add() and pr_search()
½ mark for function call statements

34 a) ECODE 4
b) INSERT INTO EMPLOYEE VALUES(109,”Abhishek
Hota”,”MANAGER”,”S01”, “05-01-2020”);
c) UPDATE EMPLOYEE SET NAME=”Rashmi Arora” WHERE
ECODE=103;
d) ALTER TABLE EMPLOYEE ADD ADDRESS CHAR(30);
1markfor each correct answer
35 (a) pickle 4
(b)wb
(c) rb
(d) file2.close( )

1markfor each correct answer


SAMPLE QUESTION PAPER - 6
SESSION 2022-23
Class: XII F.M: 70
Sub: Computer science Time : 3 hours

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions 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 Q35
against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION – A
1 Write the type of tokens from the following:- 1
(i) if (ii)rollno
2 Which of the following is valid arithmetic operator in Python? 1
(a) //(b) ?(c) <(d) and
3 Given the following declaration of dictionary? 1
Which statement is the correct one?

a. d={1:‟monday‟,2:‟tuesday‟}
b. d={1;‟monday‟,2;‟tuesday‟}
c. d=[1:‟monday‟,2:‟tuesday‟]
d. d={1‟monday‟,2‟tuesday‟}
4 Consider the given expression: 1
not True or False and True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
5 T=(23,3,4,45,56,67,78,89) 1
Write the output of print(T[:6])
(a) 23,3,4,45,56,67
(b) 23,3,4,45,56,67,78
(c) 23,3,4,45,56,67,78,89
(d) 3,4,45,56,67,78,89
6 Which of the following mode in file opening statement results or generates 1
an error if the file does not exist?

(a) a+ (b) r+ (c) w+ (d) None of the above

7 Fill in the blank: 1


______ command is used to modifythe datatype of a field in the table in
SQL.

(a) update (b)remove (c) alter (d)drop

8 Which of the following command will delete the field from the table from 1
MYSQL database?

(a) DELETE FIELD


(b) DROP TABLE
(c) REMOVE TABLE
(d) ALTER TABLE
9 Which of the following statement(s) would give an error after executing 1
the following code?

S="Welcome to class XII" # Statement 1


print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10 Fill in the blank: 1

_________ is a non-key attribute, whose values are derived from the


primary key of some other table.

(a) Primary Key


(b) Foreign Key
(c) Candidate Key
(d) Alternate key
11 The correct syntax of tell() is: 1

(a) file_object.tell()
(b) tell(offset,reference_point])
(c) x.tell(file_object)
(d) x=file_object.tell()
12 The clausethat displays the field names with their data types of a table 1
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
13 Fill in the blank: 1
______is a communication methodology designed to transfer the files over
Internet.

(a) VoIP (b) SMTP (c) FTP(d)HTTP

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


print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5

15 Which function is used to display the total mark secured by all students 1
having the fields rollno , name and marks ?
(a) sum(mark)
(b) total(mark)
(c) count(mark)
(d) return(totalmark)
16 To establish a connection between Python and SQL database, connect() is 1
used. Which of the following arguments may not necessarily be given
while calling connect() ?
(a) host
(b) database
(c) user
(d) password

Q17 and Q18 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):- If the arguments in function call statement match the 1


number and order of arguments as defined in the function definition, such
arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
18 Assertion (A): CSV (Comma Separated Values) is a file format for data 1
storage which looks like a text file.
Reason (R): The information is organized with one record on each line and
each field is separated by comma.
SECTION – B
19 Rao has written a code to input a number and check whether it is prime or 2
not. His code is having errors. Rewrite the correct code and underline the
corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n‟)
20 Write two points of difference between dedicated and non – dedicated 2
server.
OR
Write two points of difference between Hackers and Crackers.
21 (a) Given is a Python string declaration.Write the output of: 2

myexam="@@CBSE Examination 2022@@"


print(myexam[::-3])

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

my_dict = {"name": "Aman", "age": 26}


my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.keys())

22 Explain the use of „default constraint‟ in a Relational Database 2


Management System. Give example to support your answer.

23 (a) Write the full forms of the following: 1


(i) SLIP (ii) GSM
(b) What is the use of COOKIES ? 1
24 Predict the output of the Python code given below: 2
def Diff(N1,N2):
if N1>N2:
return N1 + N2
else:
return N2 - N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
OR
Predict the output of the Python code given below:
tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2!=0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
25 Differentiate between WHEREand HAVINGclause in SQL with 2
appropriate example.
OR

Categorize the following commands as DDL or DML:


INSERT, UPDATE, ALTER, DROP
SECTION C
26 (a) Consider the following tables – foods and company: 1+2
Table: foods
+------------+--------------------+------------------+--------------------+
| ITEM_ID | ITEM_NAME | ITEM_UNIT | COMPANY_ID |
+------------+-------------------+-------------------+--------------------+
|1 | Chex Mix | Pcs | 16 |
|6 | Cheez-It | Pcs | 15 |
|2 | BN Biscuit | Pcs | 15 |
|3 | Mighty Munch | Pcs | 17 |
|4 | Pot Rice | Pcs | 15 |
|5 | Jaffa Cakes | Pcs | 18 |
|7 | Salt n Shake | Pcs | |
+------------+-------------------+------------------+---------------------+

Table: company
+---------------------+--------------------------+-------------------------+
| COMPANY_ID | COMPANY_NAME | COMPANY_CITY |
+---------------------+--------------------------+-------------------------+
| 18 | Order All | Boston |
| 15 | Jack Hill Ltd | London |
| 16 | Akas Foods | Delhi |
| 17 | Foodies. | London |
| 19 | sip-n-Bite. | New York |
+---------------------+--------------------------+--------------------------+

What will be the output of the following statement?


SELECT * FROM foods NATURAL JOIN company;

(b) Write the output of the queries (i) to (iv) based on the table, PET given
below:
Table: PET
NAME OWNER SPECIES SEX BIRTH DEATH
FLUFFY HAROLD CAT F 1999-02-04 NULL
CLAWS GWEN CAT F 1994-03-17 NULL
BUFFY HAROLD DOG F 1989-05-13 NULL
FANG BENNY DOG M 1999-08-27 NULL
BROWSER DIANE DOG M 1998-08-31 1995-07-29
CHIRPY GWEN BIRD F 1998-09-11 NULL
WHISTLER GWEN BIRD 1997-12-09 NULL
SLIM BENNY SNAKE M 1996-04-29 NULL

(i) SELECT DISTINCT SPECIESFROMPET;


(ii) SELECT SPECIES,COUNT(*) FROM PET GROUP BY SPECIES
HAVING COUNT(SPECIES)>1;
(iii) SELECT NAME FROM PET WHERE SEX=‟F‟ ORDER BY
NAME;
(iv) SELECT OWNER FROM PET WHEREBIRTH BETWEEN „1998-
01-01‟ AND „1998-12-31‟;

27 Write a method COUNTLINES() in Python to read lines from text file 3


„TESTFILE.TXT‟ and display the count of lines which are starting with
any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone‟s safety.
A marked difference will come in our country.

The COUNTLINES() function should display the output as:


The number of lines starting with any vowel - 2
OR
Write a function TDCount() in Python, which should read each character
of a text file “TESTFILE.TXT” and then count and display the count of
occurrence of alphabets D and T individually (including small cases t and
d too).

Example:
If the file content is as follows:

Today is a pleasantday.
It might rain today.
It is mentioned on weather sites
The TDount() function should display the output as:
D or d: 4
T or t : 9
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 2+1
EMPLOYEE and DEPARTMENT given below:
Table :EMPLOYEE
EMPID NAME DOB DEPTID DESIG SALARY
120 ALISHA 23-JAN-1978 D001 MANAGER 75000
123 NITIN 10-OCT-1977 D002 AO 59000
129 NAVJOT 12-JUL-1971 D003 SUPERVISOR 40000
130 JIMMY 30-DEC-1980 D004 SALES REP
131 FAIZ 06-APR-1984 D001 DEP MANAGER 65000

TABLE:DEPARTMENT
DEPTID DEPTNAME FLOORNO
D001 PERSONAL 4
D002 ADMIN 10
D003 PRODUCTION 1
D004 SALES 3
(a)
(i) SELECT DEPTID, avg(salary) FROM EMPLOYEE
GROUP BY DEPTID;
(ii) SELECT MAX(DOB),MIN(DOB) FROM Employee;
(iii) SELECT Name, Salary, T.DEPTID
FROM EMPLOYEE T, DEPARTMENT P
WHERE T.DEPTID = P.DEPTID AND Salary>40000;
(iv) SELECT NAME, DESIG
FROM EMPLOYEE T, DEPARTMENT P
WHERE EMPID =129 AND T.DEPTID=P.DEPTID;
(b) Write the command to view all tables in a database.
29 Write a function INDEX_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named
„indexList‟ that stores the indices of all Non-multiples of 3 Elements of L.
For example:
If L contains [12,4,18,56]
The indexList will have - [1,3]
30 A list contains following record of a STUDENT: 3
[name, Phone_number, City]
Write the following user defined functions to perform given operations on
the stack named „status’:
(i) Push_element() - To Push an object containing name and Phone
number of STUDENT who live in BBSR to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in the stack.
For example:
If the lists of STUDENT details are:
[“Gurdas”, “99999999999”,”BBSR”]
[“Julee”, “8888888888”,”RKL”]
[“Murugan”,”77777777777”,”CTC”]
[“Ashmit”, “1010101010”,”BBSR”]

The stack should contain


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty
OR
Write a function in Python, Push(SItem) where , SItem is a dictionary
containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the
stack.
For example:
If the dictionary contains the following data:
SItem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

The stack should contain


Notebook
Pen
The output should be:
The count of elements in the stack is 2
SECTION D
31 Lucky Corporation has set up its new centre at Noida,Uttar Pradesh for its 5
office and web-based activities. It has 4 blocks of buildings as Block A
,Block B ,Block C and Block D :-
Distance between the various blocks is as follows
A to B = 40 m
B to C = 120m
C to D = 100m
A to D = 170m
B to D = 150m
A to C = 70m

Distance between various locations:

Block A - 25
Block B - 50
Block C - 125
Block D - 10

a. Suggest and draw the cable layout to efficiently connect various blocks
of buildings within the Noida center for connecting the digital devices

b. Suggest the placement of the following device with justification


i. Repeater ii. Hub/Switch

c. Which kind of network (PAN/LAN/WAN) will be formed if the Noida


office is connected to its head office in Mumbai?

d. Which fast and very effective wireless transmission medium should


preferably be used to connect the head office at Mumbai with the
center at Noida?

e. Suggest the most appropriate block/location to house the SERVER to get the
best and effective connectivity. Justify your answer.
32 (a) Write the output of the code given below: 2+3
p=5
def sum(q,r=2):
global p
p=r+q*2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)

(b) The code given below inserts the following record in the table Student:
RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and MYSQL:


 Username is scott
 Password is tiger
 The table exists in a MYSQL database named dav.
 The details (RollNo,Name,Clasand Marks)are to be accepted from
theuser.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="scott",passwd="tiger",
database="dav")
mycursor=_________________ #Statement 1
r=int(input("Enter Roll Number :: "))
n=input("Enter name :: ")
c=int(input("Enter class :: "))
m=int(input("Enter Marks :: "))
querry="insert into student values({},'{}',{},{})".format(r,n,c,m)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")

OR

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

s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

(b) The code given below reads the following record from the table
named student and displays only those records who have marks less
than 60:

RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and


MYSQL:
 Username is scott
 Password is tiger
 The table exists in a MYSQL database named dav.

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
students whose marks are less than 60.
Statement 3- to read the complete result of the query (records whose
marks are less than 60) into the object named data, from
thetable student in the database.

import mysql.connector as mysql


def sql_data():

con1=mysql.connect(host="localhost",user="root"
,password="tiger", database="school")
mycursor=_______________ #Statement 1
print("Students with marks less than 60 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

33 What is the advantage of using a csv file for permanent storage? 5


Write a Program in Python that defines and calls the following user
defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file
„record.csv‟. Each record consists of a list with field elements as empid,
name and mobile to store employee id, employee name and employee
salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file
named „record.csv‟.
OR

Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user
defined functions:
(i) add() – To accept and add data of an employee to a CSV file
„furdata.csv‟. Each record consists of a list with field elements as
fid,fname and fprice to store furniture id, furniture name and furniture
price respectively.
(ii) search()- To display the records of the furniture whose price is less
than 10000.
SECTION E
34 Navdeep creates a table RESULT with a set of records to maintain the 1+1+2
marks secured by students in Sem1, Sem2, Sem3 and their division. After
creation of the table, he has entered data of 7 students in the table.

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, that can be considered as Primary
key.
(ii) If two columns are added and 2 rows are deleted from the table result,
what will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475, Div – I.
b. Increase the SEM2 marks of the students by 3% whose name starts with
„N‟.
OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype as varchar ofsize10

35 Satya is a Python programmer. He has written a code and created a binary


file record.dat with employeeid, ename and salary. The file contains 10 1+1+2
records.
He now has to update a record based on the employee id entered by the
user and update the salary. The updated record is then to be written in the
file temp.dat. The records which are not to be updated also have to be
written to the file temp.dat. If the employee id is not found, an appropriate
message should to be displayed.
As a Python expert, help him to complete the following code based on the
requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()

(i) Which module should be imported in the program? (Statement 1)

(ii) Write the correct statement required to open a temporary file named
temp.dat. (Statement 2)

(iii) Which statement should Satya fill in Statement 3 to read the data from
the binary file, record.dat and in Statement 4 to write the updated data in
the filetemp.dat?
MARKING SCHEME - 6
SESSION 2022-23
Class: XII F.M: 70
Sub: Computer science (083) Time : 3 hours

SECTION – A
1 Write the type of tokens from the following:- 1
(i) if (ii)rollno
Ans: (i) keyword (ii) identifier

(½ mark each correct answer)


2 Which of the following is valid arithmetic operator in Python? 1
(a) //(b) ?(c) <(d) and
Ans: (a) //
(1 mark correct answer)
3 Given the following declaration of dictionary? 1
Which statement is the correct one?

a. d={1:‟monday‟,2:‟tuesday‟}
b. d={1;‟monday‟,2;‟tuesday‟}
c. d=[1:‟monday‟,2:‟tuesday‟]
d. d={1‟monday‟,2‟tuesday‟}
Ans:-a
(1 mark correct answer)
4 Consider the given expression: 1
not True or False and True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Ans: b
(1 mark correct answer)
5 T=(23,3,4,45,56,67,78,89) 1
Write the output of print(T[:6])
(a) 23, 3, 4, 45, 56, 67
(b) 23,3,4,45,56,67,78
(c) 23,3,4,45,56,67,78,89
(d) 3,4,45,56,67,78,89

Ans: a
(1 mark correct answer)
6 Which of the following mode in file opening statement results or generates 1
an error if the file does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above

Ans: (b)
(1 mark correct answer)
7 Fill in the blank: 1
______ command is used to modifythe datatype of a field in the table in
SQL.

(a) update (b)remove (c) alter (d)drop

Ans:(C) alter
(1 mark correct answer)
8 Which of the following command will delete the field from the table from 1
MYSQL database?

(a) DELETE FIELD


(b) DROP TABLE
(c) REMOVE TABLE
(d) ALTER TABLE

Ans: (d)
(1 mark correct answer)
9 Which of the following statement(s) would give an error after executing 1
the following code?

S="Welcome to class XII" # Statement 1


print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5

(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5

Ans:(b)
(1 mark correct answer)
10 Fill in the blank: 1

_________ is a non-key attribute, whose values are derived from the


primary key of some other table.

(a) Primary Key


(b) Foreign Key
(c) Candidate Key
(d) Alternate key
Ans:(b)
(1 mark correct answer)
11 The correct syntax of tell() is: 1

(a) file_object.tell()
(b) tell(offset,reference_point])
(c) x.tell(file_object)
(d) x=file_object.tell()

Ans:(d)
(1 mark correct answer)
12 The clausethat displays the field names with their data types of a table 1
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL

Ans:(a)
(1 mark correct answer)
13 Fill in the blank: 1
______is a communication methodology designed to transfer the files over
Internet.

(a) VoIP (b) SMTP (c) FTP(d)HTTP

Ans:(c)
(1 mark correct answer)
14 What will the following expression be evaluated to in Python? 1
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
Ans:(a)
(1 mark correct answer)
15 Which function is used to display the total mark secured by all students 1
having the fields rollno , name and marks ?
(a) sum(mark)
(b) total(mark)
(c) count(mark)
(d) return(totalmark)
Ans:(a)
(1 mark correct answer)
16 To establish a connection between Python and SQL database, connect() is 1
used. Which of the following arguments may not necessarily be given
while calling connect() ?
(a) host
(b) database
(c) user
(d) password
Ans:(b)
(1 mark correct answer)
Q17 and Q18 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):- If the arguments in function call statement match the 1


number and order of arguments as defined in the function definition, such
arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).

Ans:(c)
(1 mark correct answer)
18 Assertion (A): CSV (Comma Separated Values) is a file format for data 1
storage which looks like a text file.
Reason (R): The information is organized with one record on each line and
each field is separated by comma.

Ans:(a)
(1 mark correct answer)
SECTION – B
19 Rao has written a code to input a number and check whether it is prime or 2
not. His code is having errors. Rewrite the correct code and underline the
corrections made.
def prime():
n=int(input("Enter number to check :: ")
for i in range (2, n//2):
if n%i=0:
print("Number is not prime \n")
break
else:
print("Number is prime \n‟)
Ans:
def prime():
n=int(input("Enter number to check :: "))#bracket missing
for i in range (2, n//2):
if n%i==0: # = missing
print("Number is not prime \n")
break#wrong indent
else:
print("Number is prime \n”) # quote mismatch

(½ mark for each correct correction made and underlined.)


20 Write two points of difference between dedicated and non – dedicated 2
server.
OR
Write two points of difference between Hackers and Crackers.

Ans:

Dedicated server is the practice of having a unique IP and specific server


serving only for you, while in non dedicated server a number of websites
and people can benefit from the same server.

OR

Ans:
Hackers are good people who hack devices and systems with good intentions.
They might hack a system for a specified purpose or for obtaining more
knowledge out of it. Crackers are people who hack a system by breaking into it
and violating it with some bad intentions.

(1 mark for each correct difference)


(Any relevant answer can be awarded marks)
21 (a) Given is a Python string declaration.Write the output of: 2

myexam="@@CBSE Examination 2022@@"


print(myexam[::-3])

Ans:@2 ina B@

(1 mark for correct answer)

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

my_dict = {"name": "Aman", "age": 26}


my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.keys())

Ans: dict_keys([('name','age',‟address‟)])

(1 mark for correct answer)

22 Explain the use of „default constraint‟ in a Relational Database 2


Management System. Give example to support your answer.

Ans:
The DEFAULT constraint is used to set a default value for a column. The
default value will be added to all new records, if no other value is specified

Examples: CREATE TABLE t1 ( i INT DEFAULT -1, c VARCHAR(10) , price


DOUBLE(16,2));

(1 mark for correct explanation)


(1 mark for correct example)
23 (a) Write the full forms of the following: 1
(i) SLIP (ii) GSM

SLIP-SERIAL LINE INTERNET PROTOCOL


GSM-GLOBAL SYSTEM FOR MOBILE COMMUNICATIONS

( ½ mark for each correct answer)

(b) What is the use of COOKIES ? 1


Cookies are small pieces of text sent to your browser by a website you visit. They help
that website remember information about your visit .

(1 mark for correct answer)


24 Predict the output of the Python code given below: 2
def Diff(N1,N2):
if N1>N2:
return N1 + N2
else:
return N2 - N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

Ans:33#
(2 mark for correct answer)
OR
Predict the output of the Python code given below:
tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2!=0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
Ans:(11, 33, 55)

(½ mark for each correct digit , ½ mark for enclosing in parenthesis)


25 Differentiate between whereand havingclause in SQL with appropriate 2
example.
Ans:
WHERE is used to check for individual records while HAVING is used to
check for group of records.
SELECT NAME FROM PET WHERE SEX=‟F‟ ORDER BY NAME;
SELECT SPECIES,COUNT(*) FROM PET GROUP BY SPECIES
HAVING COUNT(SPECIES)>1;

(1 mark for the difference and 1 mark for appropriate example)

OR

Categorize the following commands as DDL or DML:


INSERT, UPDATE, ALTER, DROP

Ans:
DDL- ALTER, DROP
DML – INSERT, UPDATE

(½ mark for each correct categorization)

SECTION C
26 (a) Consider the following tables – foods and company: 1+2
Table: foods
+------------+--------------------+------------------+--------------------+
| ITEM_ID | ITEM_NAME | ITEM_UNIT | COMPANY_ID |
+------------+-------------------+-------------------+--------------------+
|1 | Chex Mix | Pcs | 16 |
|6 | Cheez-It | Pcs | 15 |
|2 | BN Biscuit | Pcs | 15 |
|3 | Mighty Munch | Pcs | 17 |
|4 | Pot Rice | Pcs | 15 |
|5 | Jaffa Cakes | Pcs | 18 |
|7 | Salt n Shake | Pcs | |
+------------+-------------------+------------------+---------------------+

Table: company
+---------------------+--------------------------+-------------------------+
| COMPANY_ID | COMPANY_NAME | COMPANY_CITY |
+---------------------+--------------------------+-------------------------+
| 18 | Order All | Boston |
| 15 | Jack Hill Ltd | London |
| 16 | Akas Foods | Delhi |
| 17 | Foodies. | London |
| 19 | sip-n-Bite. | New York |
+---------------------+--------------------------+--------------------------+
What will be the output of the following statement?
SELECT * FROM foods NATURAL JOIN company;

Ans:

COMPANY_ID ITEM_ID ITEM_NAME ITEM_UNIT COMPANY_NAME


COMPANY_CITY
---------- ------- ------------ ---------- -------------
------------
16 1 Chex Mix Pcs Akas
Foods Delhi
15 6 Cheez-It Pcs Jack Hill
Ltd London
15 2 BN Biscuit Pcs Jack Hill
Ltd London
17 3 Mighty Munch Pcs Foodies.
London
15 4 Pot Rice Pcs Jack Hill
Ltd London
18 5 Jaffa Cakes Pcs Order All
Boston

(1 mark for correct output)

(b) Write the output of the queries (i) to (iv) based on the table, PET given
below:
Table: PET
NAME OWNER SPECIES SEX BIRTH DEATH
FLUFFY HAROLD CAT F 1999-02-04 NULL
CLAWS GWEN CAT F 1994-03-17 NULL
BUFFY HAROLD DOG F 1989-05-13 NULL
FANG BENNY DOG M 1999-08-27 NULL
BROWSER DIANE DOG M 1998-08-31 1995-07-29
CHIRPY GWEN BIRD F 1998-09-11 NULL
WHISTLER GWEN BIRD 1997-12-09 NULL
SLIM BENNY SNAKE M 1996-04-29 NULL

(i) SELECT DISTINCT SPECIESFROMPET;


(ii) SELECT SPECIES, COUNT (*) FROM PET GROUP BY SPECIES
HAVING COUNT(SPECIES)>1;
(iii) SELECT NAME FROMPET WHERESEX=‟F‟ ORDER BY NAME;
(iv) SELECT OWNER FROM PET WHEREBIRTH BETWEEN„1998-
01-01‟ AND „1998-12-31‟;

Ans:
I) DISTINCT SPECIES
CAT
DOG
BIRD
SNAKE

II) SPECIESCOUNT(*)
CAT 2
DOG 3
BIRD 2

III)NAME
BUFFY
CHIRPY
CLAWS
FLUFFY

IV)OWNER
BOWSER
CHIRPY

( ½ mark each for the correct output)

27 Write a method COUNTLINES() in Python to read lines from text file 3


„TESTFILE.TXT‟ and display the count of lines which are starting with
any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone‟s safety.
A marked difference will come in our country.

The COUNTLINES() function should display the output as:


The number of lines starting with any vowel: 2
Ans:
def COUNTLINES():
file = open ('TESTFILE.TXT', 'r')
lines = file.readlines()
count=0
for w in lines :
if (w[0]).lower() in 'aeoiu':
count = count + 1
print ("The number of lines starting with any vowel: ",
count)
file.close()

COUNTLINES()

( ½ mark for correctly opening and closing the file


½ for readlines()
½ mark for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)

OR
Write a function TDCount() in Python, which should read each character
of a text file “TESTFILE.TXT” and then count and display the count of
occurrence of alphabets D and T individually (including small cases t and
d too).

Example:
If the file content is as follows:

Today is a pleasant day.


It might rain today.
It is mentioned on weather sites

The TDCount() function should display the output as:


D or d: 4
T or t : 9

Ans:
def TDCount():
file = open ('TESTFILE.TXT', 'r')
lines = file.readlines()
countE=0
countT=0
for w in lines :
for ch in w:
if ch in 'Dd':
countE = countE + 1
if ch in 'Tt':
countT=countT + 1
print ("D or d : ", countE)
print ("T or t : ", countT)
file.close()

TDCount()
(½ mark for correctly opening and closing the file
½ for readlines()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)
Note: Any other relevant and correct code may be marked

28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 2+1
EMPLOYEE and DEPARTMENT given below:
Table :EMPLOYEE
EMPID NAME DOB DEPTID DESIG SALARY
120 ALISHA 23-JAN-1978 D001 MANAGER 75000
123 NITIN 10-OCT-1977 D002 AO 59000
129 NAVJOT 12-JUL-1971 D003 SUPERVISOR 40000
130 JIMMY 30-DEC-1980 D004 SALES REP
131 FAIZ 06-APR-1984 D001 DEP MANAGER 65000

TABLE:DEPARTMENT
DEPTID DEPTNAME FLOORNO
D001 PERSONAL 4
D002 ADMIN 10
D003 PRODUCTION 1
D004 SALES 3
(a)
(i) SELECT DEPTID, avg(salary) FROM EMPLOYEE GROUP BY
DEPTID;
(ii) SELECT MAX(DOB),MIN(DOB) FROM Employee;
(iii) SELECT Name, Salary, T.DEPTID FROM EMPLOYEE T,
DEPARTMENT P WHERE T.DEPTID = P.DEPTID AND Salary>40000;
(iv) SELECT Name, DESIG FROM EMPLOYEE T, DEPARTMENT P
WHERE EMPID =129 AND T.DEPTID=P.DEPTID;
Ans:
i) deptidavg(salary)
D001 70000
D002 59000
D003 40000
D004

II)MAX(DOB) MIN(DOB)
06-APR-1984 12-JUL-1971

III)NAME SALARY T.DEPTID


ALISHA 75000 D001
NITIN 59000 D002
JIMMY D004
FAIZ 65000 D001

IV) NAME DESIG


NAVJOT SUPERVISOR.

( ½ mark each for correct answer)


(b) Write the command to view all tables in a database.
Ans: show tables;

(1 mark for correct answer)


29 3
Write a function INDEX_LIST(L), where L is the list of elements passed
as argument to the function. The function returns another list named
„indexList‟ that stores the indices of all Non-multiples of 3 Elements of L.
For example:
If L contains [12,4,18,56]
The indexList will have - [1,3]
Ans:
def INDEX_LIST(L):
indexList=[]
for i in range(len(L)):
if L[i]%3!=0:
indexList.append(i)
return indexList
(½ mark for correct function header
1 mark for correct loop
1 mark for correct if statement
½ mark for return statement)
Note: Any other relevant and correct code may be marked

30 A list contains following record of a STUDENT: 3


[name, Phone_number, City]
Write the following user defined functions to perform given operations on
the stack named „status’:
(i) Push_element() - To Push an object containing name and Phone
number of STUDENT who live in BBSR to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in the stack.
For example:
If the lists of STUDENT details are:
[“Gurdas”, “99999999999”,”BBSR”]
[“Julee”, “8888888888”,”RKL”]
[“Murugan”,”77777777777”,”CTC”]
[“Ashmit”, “1010101010”,”BBSR”]

The stack should contain


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]

The output should be:


[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
Stack Empty

Ans:
status=[]
def Push_element(cust):
if cust[2]==" BBSR ":
L1=[cust[0],cust[1]]
status.append(L1)
def Pop_element ():
num=len(status)
while len(status)!=0:
dele=status.pop()
print(dele)
num=num-1
else:
print("Stack Empty")

(1.5 marks for correct push_element() and 1.5 marks for correct pop_element())

OR
Write a function in Python, Push(SItem) where , SItem is a dictionary
containing the details of stationary items– {Sname:price}.
The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the
stack.
For example:
If the dictionary contains the following data:
SItem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}

The stack should contain


Notebook
Pen
The output should be:
The count of elements in the stack is 2
Ans:

stackItem=[]
def Push(SItem):
count=0
for k in SItem:
if (SItem[k]>75):
stackItem.append(k)
count=count+1
print("The count of elements in the stack is : ", count)

(1 mark for correct function header


1 mark for correct loop
½ mark for correct If statement
½ mark for correct display of count)

SECTION D
31 Lucky Corporation has set up its new centre at Noida,Uttar Pradesh for its 5
office and web-based activities. It has 4 blocks of buildings as Block A
,Block B ,Block C and Block D :-
Distance between the various blocks is as follows
A to B = 40 m
B to C = 120m
C to D = 100m
A to D = 170m
B to D = 150m
A to C = 70m

Distance between various locations:


Block A - 25
Block B - 50
Block C - 125
Block D - 10

a. Suggest and draw the cable layout to efficiently connect various blocks
of buildings within the Noida center for connecting the digital devices

(1 mark for correct layout)

b. Suggest the placement of the following device with justification


i. Repeater ii. Hub/Switch
Ans:
Switch/hub will be placed in all blocks to have connectivity within the block.
Repeater is required between the Block Cand Block D , Block C and Block B as
the distances is more or equal to 100 mts.
(1 mark for the correct answer)

c. Which kind of network (PAN/LAN/WAN) will be formed if the Noida


office is connected to its head office in Mumbai?

WAN
(1 mark for the correct answer)

d. Which fast and very effective wireless transmission medium should


preferably be used to connect the head office at Mumbai with the
center at Noida?

Satellite

(1 mark for the correct answer)

e.Suggest the most appropriate block/location to house the SERVER to get the
best and effective connectivity. Justify your answer.

Ans: Block C is the most appropriate to house the server as it has the
maximum number of computers.

( ½ mark for naming the server block and ½ mark for correct reason.)

32 (a) Write the output of the code given below: 2+3


p=5
def sum(q,r=2):
global p
p=r+q*2
print(p, end= '#')
a=10
b=5
sum(a,b)
sum(r=5,q=1)

Ans:

25#7#

(1 mark for 25# and 1 mark for 7#)

(b) The code given below inserts the following record in the table Student:
RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and MYSQL:


 Username is scott
 Password is tiger
 The table exists in a MYSQL database named dav.
 The details (RollNo,Name,Clasand Marks)are to be accepted from
theuser.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="scott",passwd="tiger",
database="dav")
mycursor=_________________ #Statement 1
r=int(input("Enter Roll Number :: "))
n=input("Enter name :: ")
c=int(input("Enter class :: "))
m=int(input("Enter Marks :: "))
querry="insert into student values({},'{}',{},{})".format(r,n,c,m)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")

Ans:
con1.cursor()# Statement 1:
mycursor.execute(querry) #Statement 2:
con1.commit() #Statement 3:
(1 mark for each correct answer)
OR

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

s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)

Ans:
sELCcME&Cc
(1 mark for first 5 characters, 1 mark for next 5 characters)

(b) The code given below reads the following record from the table
named student and displays only those records who have marks less
than 60:

RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python and


MYSQL:
 Username is scott
 Password is tiger
 The table exists in a MYSQL database named dav.

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
students whose marks are less than 60.
Statement 3- to read the complete result of the query (records whose
marks are less than 60) into the object named data, from
thetable student in the database.

import mysql.connector as mysql


def sql_data():
con1=mysql.connect(host="localhost",user="scott"
,password="tiger", database="dav")
mycursor=_______________ #Statement 1
print("Students with marks less than 60 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
Ans:
Statement 1:
con1.cursor()
Statement 2:
mycursor.execute("select * from student where Marks<60")
Statement 3:
mycursor.fetchall()
33 What is the advantage of using a csv file for permanent storage? 5
Write a Program in Python that defines and calls the following user
defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file
„record.csv‟. Each record consists of a list with field elements as empid,
name and mobile to store employee id, employee name and employee
salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file
named „record.csv‟.

Ans:
Advantage of a csv file:
It is human readable – can be opened in Excel and Notepad applications
 It is just like text file

Program:
import csv
def ADD():
fout=open("record.csv","a",newline="\n")
wr=csv.writer(fout)
empid=int(input("Enter Employee id :: "))
name=input("Enter name :: ")
mobile=int(input("Enter mobile number :: "))
lst=[empid,name,mobile] --------- ½ mark
wr.writerow(lst) --------- ½ mark
fout.close()

def COUNTR():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
d=list(data)
print(len(d))
fin.close()

ADD()
COUNTR()
(1 mark for advantage
½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and COUNTR()
½ mark for function call statements
)
OR

Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user
defined functions:
(i) add() – To accept and add data of an employee to a CSV file
„furdata.csv‟. Each record consists of a list with field elements as
fid,fname and fprice to store furniture id, furniture name and furniture
price respectively.
(ii) search()- To display the records of the furniture whose price is less
than 10000.

Ans:
Difference between binary file and csv file: (Any one difference may be
given)
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

Program:
import csv
def add():
fout=open("furdata.csv","a",newline='\n')
wr=csv.writer(fout)
fid=int(input("Enter Furniture Id :: "))
fname=input("Enter Furniture name :: ")
fprice=int(input("Enter price :: "))
FD=[fid,fname,fprice]
wr.writerow(FD)
fout.close()

def search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])<10000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
add()
print("Now displaying")
search()
(1 mark for difference
½ mark for importing csv module
1 ½ marks each for correct definition of add() and search()
½ mark for function call statements
)

SECTION E
34 Navdeep creates a table RESULT with a set of records to maintain the 1+1+2
marks secured by students in Sem1, Sem2, Sem3 and their division. After
creation of the table, he has entered data of 7 students in the table.

Based on the data given above answer the following questions:


(i) Identify the most appropriate column, that can be considered as Primary
key.

Ans: ROLL_NO
(1 mark for correct answer)

(ii) If two columns are added and 2 rows are deleted from the table result,
what will be the new degree and cardinality of the above table?

Ans:
New Degree: 6
New Cardinality: 5
( ½ mark for correct degree and ½ mark for correct cardinality)

(iii) Write the statements to:


a. Insert the following record into the table
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475, Div – I.
b. Increase the SEM2 marks of the students by 3% whose name starts with
„N‟.
Ans:
a. INSERT INTO RESULT VALUES (108, „Aadit‟, 470, 444, 475, „I‟);
b. UPDATE RESULT SET SEM2=SEM2+ (SEM2*0.03) WHERE SNAME LIKE “N%”;

( ½ mark for each correct statement)


OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype as varchar ofsize10

Ans:
a. DELETE FROM RESULT WHERE DIV=‟IV‟;
b. ALTER TABLE RESULT ADD (REMARKS VARCHAR(10));

( ½mark for each correct statement)


35 Satya is a Python programmer. He has written a code and created a binary
file record.dat with employeeid, ename and salary. The file contains 10 1+1+2
records.
He now has to update a record based on the employee id entered by the
user and update the salary. The updated record is then to be written in the
file temp.dat. The records which are not to be updated also have to be
written to the file temp.dat. If the employee id is not found, an appropriate
message should to be displayed.
As a Python expert, help him to complete the following code based on the
requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()

(i) Which module should be imported in the program? (Statement 1)

Ans: pickle
(1 mark for correct module)

(ii) Write the correct statement required to open a temporary file named
temp.dat. (Statement 2)

Ans: fout=open(„temp.dat‟, „wb‟)


(1 mark for correct statement)

(iii) Which statement should Satya fill in Statement 3 to read the data from
the binary file, record.dat and in Statement 4 to write the updated data in
the filetemp.dat?

Ans: Statement 3: pickle.load(fin)


Statement 4: pickle.dump(rec,fout)
(1 mark for each correct statement)
SET NO-01
Roll No. Candidates must write the Set No. on
the title page of the answer book.

SAMPLE QUESTION PAPER-7 (2022-23)

 Please check that this question paper contains 11printed pages.


 Set number given on the right hand side of the question paper should be
written on the title page of the answer book by the candidate.
 Check that this question paper contains 35 questions.
 Write down the Serial Number of the question in the left side of the margin
before attempting it.
 15 minutes time has been allotted to read this question paper. The question
paper will be distributed 15 minutes prior to the commencement of the
examination. The students will read the question paper only and will not
write any answer on the answer script during this period.

CLASS- XII
SUB : COMPUTER SCIENCE( 083 )
Time : 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 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 Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. State True or False: 1
In a Python code, the comments are given by using * and ** signs.
2. The data type of an expression float(m)/int(n) will result in: 1
(a) int (b) float (c) int or float (d) None of these

COMPUTER SCIENCE –XII/SQP-1Page 1 of 11


3. Which of the following statements is correct to display the key:value 1
pairs of a dictionary?
(a) <dictionary name>.values()(b) <dictionary name>.keys()
(c) <dictionary name>.key_values() (d) <dictionary name>.items()
4. Consider the given expression: 1
not(False and True) or not(False)
Which of the following will be correct output if the given expression is
evaluated?
(a) False (b) True (c) NULL (d) None
5. Select the correct output of the code: 1
str="computer is fun"
p=len(str)
substr="FUN"
print(str.find(substr, 0, p))
(a) 13 (b) 12 (c) -1 (d) 0
6. Which of the following mode will open the file in binary and read-write 1
mode?
(a) „r‟ (b) „rb‟ (c) „r+‟ (d) „rb+‟
7. Fill in the blank: 1
DROP TABLE Employee; is a _________ type of statement.
(a) DDL (b) DCL (c) DML (d) TCL
8. Which of the following commands will make changes in the column 1
values of a table in MYSQL database?
(a) CREATE (b) UPDATE (c) ALTER (d) INSERT
9. Which of the following statement(s) would give an error after executing 1
the following code?
Y=(2, 4, 6, 7, 10) #statement 1
Y[3]=8 #statement 2
print(Y*2) #statement 3
(a) statement 1(b) statement 2
(c) statement 3 (d) None of these
10. Fill in the blank: 1
__________ table constraint will prevent the entry of duplicate rows in a
table.
(a) UNIQUE (b) DISTINCT(c)PRIMARY KEY (d) NULL
11. Which of the following will set the file pointer at the beginning of a file? 1
(a) seek(1) (b) seek(-1) (c) seek(0) (d) seek( )
12. Fill in the blank: 1
__________ command is used to change the data type of some columnof
a table in a database.
(a) UPDATE (b) CHANGE (c) ALTER (d) DROP
13. Fill in the blank: 1
__________ TCP/IP protocol is used for transferring files from one
COMPUTER SCIENCE –XII/SQP-1Page 2 of 11
computer to another.
(a) SMTP (b) PPP (c) FTP(d) HTTP
14. What will the following expression be evaluated to in Python? 1
print(20/4+(9.0+4.0))
(a) 18 (b) 18.0 (c) 5.0 (d) 5
15. Which of the following is not an aggregate function? 1
(a) MIN( ) (b) SUM( ) (c) PRODUCT( ) (d) AVG( )
16. Which of the following functions is used to execute Python interfaced 1
MySQL query?
(a) run( ) (b) execute( ) (c) operate( ) (d) None of these
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): When a function is defined with a list of parameters with 1
function name in the function header, it is known as parameterised
function.
Reason (R): A non-parameterised function does not include parameters
with the function name in the function header. Thus, the parentheses
remains empty and no arguments are passed while calling the function.
18. Assertion (A): Python provides a built-in module called csv module to 1
enable reading and writing operation in the CSV file.
Reason (R): It uses mainly the classes viz. csv.writer and csv.reader. The
csv.writer class creates a writer object to write the input data into the file.
Whereas, the csv.reader class returns a reader object to retrieve from a
csv file.
SECTION B

19. Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code.
value=30
for res in range(0, value)
If res%4==0:
print(res*4)
Elseif res%5==0:
print(res+3)
Else:
print(res+10)
20. Write two points of difference between Hub and Switch. 2

COMPUTER SCIENCE –XII/SQP-1Page 3 of 11


OR
Write two points of difference between LAN and WAN.
21. (a) Given is a Python string declaration: 1
Exam= "AISSCE 2022-23"
Predict the output of the following statement:
>>>Exam[ : : -2] 1
(b) Write the output of the following code snippet:
D={1:11, 2:20, 3:33, 4:40, 5:55}
for a in D:
if (D[a]%2==0):
D[a]*=3
else:
D[a]+=10
print(D)
22. Differentiate between COUNT() and COUNT(*) functions in SQL with 2
appropriate example.
23. (a) Write the full forms of the following: 2
(i) GSM (ii) TELNET
(b) What is a Server?
24. Predict the output of the following code snippet: 2
def Display():
a=0
print(“Output:”)
while(a<8):
a=a+1
if(a%2= = 0):
continue
print(a)
return
Display()
OR
Predict the output of the following code snippet:
TP = (15, 12, 14, 12, 15, 12, 12, 16, 12)
print(TP.count(12) + TP.index(15))
print(max(TP)-min(TP))

25. Differentiate between Candidate key and Primary key.


2
OR

(i) What is the default order of displaying the records of a table


while using ORDER BY clause?
(ii) Name any two logical operators used in SQL.

COMPUTER SCIENCE –XII/SQP-1Page 4 of 11


SECTION C
26. (a) Refer the tables given below: 1+2
Table A: Book
Code Sub
B1 English
B2 Physics
B3 History
B4 Science
Table B: Stock
SCode Pub Qty Code
P01 Gyan Chand 250 B1
P02 Pustak House 340 B2
P03 Arora 470 B3
P04 Sonka 245 B5
Predict the output for the following query:
SELECT * FROM Book INNER JOIN Stock
ON Book.Code=Stock.Code;
(b) Write the output of the queries (i) to (iv) based on the following
tables:

(i) Select DESIGNATION, COUNT (*) From ADMIN Group By


DESIGNATION Having COUNT (*) <2;
(ii) SELECT MAX (EXPERIENCE) FROM SCHOOL;
(iii) SELECT TEACHER FROM SCHOOL WHERE
EXPERIENCE >12 ORDER BY TEACHER;
(iv) SELECT COUNT (*), GENDER FROM ADMIN
GROUP BY GENDER;
27. Write a user defined function Display() in Python that displays the lines 3
ending with „h‟ or „e‟ in the file STORY.txt.
E.g: If the file contains:

COMPUTER SCIENCE –XII/SQP-1Page 5 of 11


Whose woods these are I think I know
His house is in the village though
He will not see me stopping here
To watch his woods fill up with snow
Then the function must display the following lines:
His house is in the village though
He will not see me stopping here
OR
Write a function countmy( )in Python to read the text file “Data.txt” and
count the number of times “my” or “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.
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
COMPANY and CUSTOMER.

(i) SELECT COUNT(*) , CITY FROM COMPANY


GROUP BY CITY;
(ii) SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER
WHERE QTY>10;
(iii) SELECT AVG(QTY) FROM CUSTOMER WHERE
NAMELIKE “%R%”;
(iv) SELECT PRODUCTNAME,CITY, PRICE
FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND
PRODUCTNAME= “MOBILE”;
(b) Write any two Table constraints in SQL.
29. Write a function INDEX_LIST(L), where L is the list of elements passed 3
as argument to the function. The function returns another list named
„indexList‟ that stores the indices of all those elements of L that ends
with 7.

COMPUTER SCIENCE –XII/SQP-1Page 6 of 11


For example:
If L contains [5, 7, 21, 27, 47, 14, 17]
The indexList will have [1,3,4,6]
30. Mayank has created a dictionary containing names and marks as key 3
value pairs of 6 students. Write a function in Python PushName(S) to
Push the keys (name of the student) of the dictionary S into a stack,
where the corresponding value (marks) is greater than 75. Also display
the count of elements pushed into the stack.
For example: If the sample content of the dictionary is as follows
S={"OM":66,"JAI":45,"BOB":95,"ALI":65,"ANU":90,"TOM":82}

The stack should contain


TOM
ANU
BOB
The output should be:
The count of elements in the stack is 3

OR

Sohan has a list containing 8 integers as marks of subject Science. You


need to help him to create a program with separate user defined function
to perform the following operations based on the list.
 Push those marks into a stack which are greater than 75.
 Pop and display the content of the stack.
Sample Input:
Marks = [75, 80, 56, 90, 45, 62,76, 72]
Sample Output:
76 90 80
SECTION D
31. The University is planning to start its academic blocks at Navi Mumbai 5
to setup a network. The University has 3 different blocks(Block A, Block
B, Block C) and one Administrative Block, as shown in the diagram
below:

Block A Block B Block C

Administrative Block

COMPUTER SCIENCE –XII/SQP-1Page 7 of 11


The distances between various blocks are as follows:
FROM TO DISTANCE
Block A Administrative Block 80 m
Block A Block C 80 m
Block B Administrative Block 45 m
Block B Block C 30 m
Block C Administrative Block 35 m
Block A Block B 15 m

No. of computers installed in each of the following blocks are as follows:


Name of Block No. of Computers
Block A 15
Block B 40
Block C 20
Administrative Block 80
(a) Suggest the most suitable place (i.e., Block) to install the server of
this University with a suitable reason.
(b) Suggest the ideal layout for connecting these blocks for a wired
connectivity.
(c) Which device will you suggest to be placed/installed in each of these
blocks to efficiently connect all the computers within these blocks?
(d) Suggest the placement of a repeater in the network with justification.
(e) The University is planning to connect its admission office in Delhi,
which is more than 1250 km from University. Which type of
network out of LAN, MAN, or WAN will be formed? Justify your
answer.
32. (a) Predict the output of the following program snippet. 2+3
def Case_Convert(str):
p=len(str)
str1= „‟
for i in range(0, p):
chr=str[i]
if (chr>= „a‟ and chr<= „z‟):
chr1=chr.upper()
str1=str1+chr1
elif (chr>= „A‟ and chr<= „Z‟):
chr1=chr.lower()
str1=str1+chr1
else:
str1=str1+chr
print(“The new string :”,str1)

COMPUTER SCIENCE –XII/SQP-1Page 8 of 11


str=“Python for class 12”
Case_Convert(str)

(b) The code given below intends to delete a record from the table
„Employee‟ available in the database „Company‟, whose „Dept‟ is „Elect‟
and Grade is „G4‟. Write the following missing statements to complete
the code:
Statement 1-To form the cursor object
Statement 2-To execute the command that will delete the desired record
from the table „Employee‟.
Statement 3-To make the changes after deletion of record permanently in
the database.
import mysql.connector as mycon
mydb=mycon.connect(host=„localhost‟, database=„Company‟,
user= „root‟, passwd= „1234‟)
mycursor=______________ #Statement 1
mycursor.execute ( _______________________ ) #Statement 2
mydb.____________ #Statement 3

OR
(a) Predict the output of the following program snippet.
x=5
def func2():
x=3
x=x+1
print(float(x),end=„$‟)
func2()
print(x)

(b) The management of a company has decided to increase the salary by


20% of all those employees who belong to the „Dept‟ (IT). Now, write
the following missing statements to complete the code:
Statement 1-To form the cursor object
Statement 2-To execute the command that will increase the salary by
20% of all those employees who belong to the „Dept‟ (IT).
Statement 3-To make the changes after deletion of record permanently in
the database.
import mysql.connector as mycon
mydb=mycon.connect(host=„localhost‟, database=„Company‟,
user= „root‟, passwd= „1234‟)
mycursor=______________ #Statement 1
mycursor.execute ( _______________________ ) #Statement 2
mydb.____________ #Statement 3

COMPUTER SCIENCE –XII/SQP-1Page 9 of 11


33. Name the default „delimiter‟ used in a CSV file. 5
Write a program in Python that defines and calls the following user
defined functions:
(a) ADD() – To accept and add data of Indian state to a CSV file
„Indian_Cap.csv‟. Each record consists of a list with field
elements as S.No., Indian State, Capital and Pincode
respectively.
(b) COUNT() – To count the number of records present in the CSV
file named „Indian_Cap.csv‟.
OR
What is a CSV file?
Write a program in Python that defines and calls the following user
defined functions:
(a) ADD() – To accept and add data of students to a CSV file
„student.csv‟. Each record consists of a list with field elements
as Rollno, Name, Marks respectively.
(b) Display() – To read all content of “student.csv” and display
records of only those students who scored more than 80 marks.
Records stored in students is in format : Rollno, Name, Marks.

SECTION E
34. Observe the following table and answer the parts (a) to (c): 1+1+
2

(a) Identify the most appropriate column, which can be considered as


Primary key of the Table Store.
(b) If three columns are added and one row is deleted from the table
Store, then what will be the new degree and cardinality of the
above table?
(c) Write the statements to:
(i) Insert the following record into the table:
Item Code-17, Item-CD Marker, Qty-50, Rate-10
(ii) Increase the Item Rate by 10% where the Item Code is 11.
OR(Option for Part (c) only)

(c) Write the statements to:

COMPUTER SCIENCE –XII/SQP-1Page 10 of 11


(i) Delete the record of Item having Rate less than 10.
(ii) Add a column Distributer in the table with data type as
varchar with 40 characters.
35. A binary file „Result.dat‟ contains the records(each containing names and 1+1+
marks in English, Maths and Computer Science) of all the students of 2
Class-XII. Write a function def Result( ) in Python to display the names
of all the students who have secured 90% and above in English, Maths
and Computer Science.
[Assume that the file is already present in the system.]
The code is written as follows:
# To display the records of the binary file
import __________ #Statement 1
def Result( ):
f=open( __________________ ) #Statement 2
print(“Content of the file:”)
try:
while True:
Record=________________ #Statement 3
print(Record)
print(“Name\t\t”, “English\t\t”, “Maths\t\t”,“Computer\t\t”)
for i in Record:
m1=i[1]; m2=i[2]; m3=i[3]

if( ______________________ ): #Statement 4


print(i[0], „\t‟, i[1], „\t‟, i[2], „\t‟, i[3])
except:
f.close()
print(“Program Ends!”)
# main program
Result()
(a) Which module should be imported in the program?(Statement 1)
(b) Write the correct statement required to open the
file Result.dat.(Statement 2)
(c) Which statement should be filled in Statement 3 to read a Record
from the binary file and in Statement 4 to check who have secured
90% and above in English, Maths and Computer Science from
the binary file State.dat

COMPUTER SCIENCE –XII/SQP-1Page 11 of 11


SAMPLE QUESTION PAPER (2022-23)
SUBJECT: COMPUTER SCIENCE CLASS :XII
MARKING SCHEME - 7
QSTN Marks
Value Points
NO Allotted
False
1 1
(1 mark for correct answer)

(b) float
2 1
(1 mark for correct answer)

(d) <dictionary name>.items()


3 1
(1 mark for correct answer)

(b) True 1
4 (1 mark for correct answer)

(c) -1 1
5 (1 mark for correct answer)

(d) „rb+‟ 1
6 (1 mark for correct answer)

(a) DDL
7 1
(1 mark for correct answer)

8 (b) UPDATE 1
(1 mark for correct answer)
(b) statement 2 1
9 (1 mark for correct answer)

(c)PRIMARY KEY 1
10 (1 mark for correct answer)

(c) seek(0) 1
11 (1 mark for correct answer)

(c) ALTER 1
12 (1 mark for correct answer)

(c) FTP 1
13 (1 mark for correct answer)
(b) 18.0 1
14 (1 mark for correct answer)

1
15 (c) PRODUCT( )
(1 mark for correct answer)
(b) execute( ) 1
16 (1 mark for correct answer)

17 (b) Both A and R are true and R is not the correct explanation for A 1
(1 mark for correct answer)

18 (a) Both A and R are true and R is the correct explanation for A. 1
(1 mark for correct answer)

19 Corrected code is as follows: 2


value=30
for res in range(0, value) :
if res%4==0:
print(res*4)
elif res%5==0:
print(res+3)
else:
print(res+10)
(1/2 mark for each correction)
20 Difference between Hub and Switch 2
Hub Switch
(i) Hub is an unintelligent (i) Switch is an intelligent
device. device.
(ii) Hub broadcasts the data (ii) Switch directs the data
packet to entire devices packet to a specific
connected on the network. computer or device.
OR
LAN WAN
(i)A local area network is (i) A wide area network may
restrictedto a limited operate on a worldwide or
geographical area. nationwide basis.
(ii)In a LAN, the computers, (ii) In a WAN,
theterminals and the thecommunicationmay take
peripheraldevices are place using radio wave,
connected to eachother microwave, satellite, etc.
through wires andcoaxial
cables.

(1 mark for each correct difference. 2 differences are required)


21 (a) '3-22ESI' 2
(b) {1: 21, 2: 60, 3: 43, 4: 120, 5: 65}
(1 mark for each correct output)
22 The differences between COUNT( ) and COUNT(*) are as follows: 2

23 (a) (i) GSM: Global System for Mobile Communication. 2


(ii) TELNET: Telecommunication Network.
(1/2 mark for each correct full form)

(b) A Server is a device that acts as a bridge between sender and


receiver responding requests made over a network.
(1 mark for each correct definition)
24 Output: 2
1
3
5
7
(1/2 mark for each correct value)
OR
5
4
(1 mark for each correct value)
25 The differences between the Primary key and the Candidate key are as 2
follows:
Primary key Candidate key
(i) The Primary key is a (i) A Candidate key can be
column or a combination of any column or a combination
columns that uniquely of columns that can qualify
identify a record. as „Unique key‟ in a
database.
(ii) Only one Candidate key (ii) There are multiple
can be a Primary key. Candidate keys in a table.
(1 mark for each correct difference)
OR
(a) Ascending (ASC)
(b) AND, OR, NOT (Any two)
(1 mark for each correct answer)

26 (a) Output: 3
Code Sub SCode Pub Qty Code
B1 English P01 Gyan 250 B1
Chand
B2 Physics P02 Pustak 340 B2
House
B3 History P03 Arora 470 B3
(b) Output:
(i) DESIGNATIONCOUNT (*)
--------------------------------------
VICE PRINCIPAL 1
(ii) MAX(EXPERIENCE)
----------------------------
16
(iii) TEACHER
----------------
UMESH
YASHRAJ

(iv) COUNT(*) GENDER


------------------------------
5 MALE
2 FEMALE
(1/2 mark for each correct output)

27 def Display(): 3
f=open("STORY.txt","r")
y=f.readlines()
for line in y:
if line[-2]=='h' or line[-2]=='e':
print(line)
f.close()
(½ mark for function header
½ mark for opening file
½ mark for reading
½ for loop
½ for if condition
½ mark for closing file)

OR
def countmy():
f=open("Data.txt","r")
count=0
y=f.read()
Words=y.split()
for word in Words:
if word=='my' or word=='My':
count=count+1
print("my occurs ",count," times")
f.close()
(½ mark for function header
½ mark for opening file
½ mark for reading
½ for loop
½ for if condition and counting
½ mark for closing file)
28 (a) Output: 3
(i) COUNT(*) CITY
-----------------------------
3 DELHI
2 MUMBAI
1 MADRAS
(ii) MIN(PRICE) MAX(PRICE)
-------------------------------------
50,000 70,000
(iii) AVG (QTY)
-----------------
11
(iv) PRODUCTNAMECITYPRICE
----------------------------------------------------
MOBILE MUMBAI 70,000
MOBILE MUMBAI 25,000
(½ mark for each correct output)

(b) UNIQUE, PRIMARY KEY, NOT NULL etc.(Any two)


(½ mark for each correct constraint)
29 def INDEX_LIST(L): 3
indexList=[]
for i in range(len(L)):
if L[i]%10==7:
indexList.append(i)
return indexList
(½ mark for function header
½ mark for creating empty list
½ mark for loop
½ mark for if condition
½ mark for adding element to the list
½ mark for returning list)
30 stack=[ ] #empty stack 3
def PushName(data):
stack.append(data)

#main program
S={"OM":66,"JAI":45,"BOB":95,"ALI":65,"ANU":90,"TOM":82}
count=0
for key in R:
if R[key] >75:
PUSH(stack, key)
count=count+1
print("The count of elements in the stack is ",count)

(1 mark for function PushName()


2 mark for main())

OR
stack=[]

def push(stack,item):
stack.append(item)

def POP(stack):
if stack==[]:
print("Underflow error")
return None
else:
return stack.pop()

Marks=[75, 80, 56, 90, 45, 62,76, 72]


for item in Marks:
if item>75:
push(stack,item)
while True:
if stack==[]:
break
else:
print(POP(stack),end=" ")
(1 mark for function PushName()
2 mark for main())

31 (a)Administrative Block, because it contains maximum number of 5


computers(80-20 Rule).
(b) Block Block Block
A B C
Administrative
(c)Hub/Switch
(d) Repeater is not required for this network.
(e) MAN, because of very large distance of 1250 km.
(1 for each correct answer).
32 (a) The new string :pYTHON FOR CLASS 12 5
(2 for correct output)

(b) Statement 1:mydb.cursor()


Statement 2: DELETE FROM Employee WHERE
Dept= „Elect‟ AND Grade=„G4‟
Statement 3:commit()
(1 mark for each correct answer)
OR
(a) 4.0 $ 5
(2 for correct output)
(b) Statement 1:mydb.cursor()
Statement 2:UPDATE Employee SET Salary=Salary+0.2*Salary
WHERE
Dept= „IT‟
Statement 3:commit()
(1 mark for each correct answer)
33 The default delimiter used in a CSV file is comma( , ). 5
(a) def ADD( ):
import csv
field = ["S.No." , "Indian State" , "Capital", "Pincode"]
f = open("Indian_Cap.csv" , 'w')
d=csv.writer(f)
d.writerow(field)
ch='y'
while ch=='y' or ch=='Y':
sn=int(input("Enter the serial number: "))
st = input("Enter the state: ")
capt = input("Enter the capital: ")
pin=int(input("Enter the pincode: "))
rec=[sn,st,capt, pin]
d.writerow(rec)
ch=input("Enter more record??(Y/N)")
f.close()
ADD()

(b) def COUNT( ):


import csv
f = open("Indian_Cap.csv" , "r")
d = csv.reader(f)
next(f) #to skip header row
r=0
for row in d:
r = r+1
print("Number of records are " , r)
f.close()
COUNT()
1 for correct default delimiter.
1
1 for each correct definition of function
2
½ for importing csv module
½ for calling the functions

OR
A CSV file is a simple text file format that is used to store data in tabular
form such as spreadsheet or database. It contains data(number or text) as
a set of characters.
(a) def ADD( ):
import csv
field = ["Rollno", "Name" , "Marks"]
f = open("student.csv" , 'w')
d=csv.writer(f)
d.writerow(field)
ch='y'
while ch=='y' or ch=='Y':
roll=int(input("Enter the roll number: "))
name= input("Enter the Name: ")
mark=int(input("Enter the marks: "))
rec=[roll, name, mark]
d.writerow(rec)
ch=input("Enter more record??(Y/N)")
f.close()
ADD()

(b) def Display( ):


import csv
f = open("student.csv " , "r")
d = csv.reader(f)
next(f) #to skip header row
for row in d:
if int(row[2])>80:
print(row)
f.close()
Display()

1 for correct definition of CSV file.


1
1 for each correct definition of function
2
½ for importing csv module
½ for calling the functions
34 (a) Item Code 4
(1 mark for correct answer)
(b) Degree: 7, Cardinality: 4
(1/2 mark for each correct answer)
(c) (i) INSERT INTO Store VALUES (17, „CD Marker‟, 50, 10);
(ii) UPDATE Store SET Rate=Rate+0.1*Rate WHERE Item
Code=11;
(1 mark for each correct answer)
OR
(i) DELETE FROM Store WHERE Rate<10;
(ii) ALTER TABLE Store ADD (Distributor VARCHAR(40));
(1 mark for each correct answer)
35 (a) pickle 4
(1 mark for correct answer)
(b) (“Result.dat”, “rb”)
(1 mark for correct answer)
(c) Statement 3:pickle.load(f)
Statement 4:m1>=90 and m2>=90 and m3>=90
(1 mark for each correct answer)
SAMPLE QUESTION PAPER – 8 2022-23
CLASS- XII
Time: 3hrs COMPUTER SCIENCE (083) Max. Marks: 70

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions 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 Q35
against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION-A
(1 mark to be awarded for every correct answer)
01 Write the names of the following Tokens of Python : 1
(i) if (ii) roll_no
02 Identify the valid Logical operator in Python from the following. 1
(a) OR (b) != (c) in (d) and
03 Suppose a tuple T is declared as T = (25, 37, 58, 79), which of the following is 1
incorrect?
a) print(T[1]) b) T[2] = –96
c) print(max(T)) d) print(len(T))

04 Consider the given expression: 1


20<30 and 15>7 or not 25<4
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
05 Select the correct output of the code: 1
s = "Python4 4.0 Programming Language."
s1 = s.split('4')
s2 = s1[0] + ". " + s1[1] + ". " + s1[2]
print (s2)

(a) Python. 0. Programming Language.


(b) Python. . .0 Programming Language.
(c) Python. .0 . Programming Language.
(d) Python0 Programming Language
06 Which of the following options can be used to read the first line of a text file 1
Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()

07 Which command is used to view the list of tables in a database? 1


(a) alter (b) show tables (c) view tables (d) show databases

08 ALTER TABLE is a ___________ category of SQL command. 1

a) TCL b) DML c) DCL d) DDL


09 Identify the output of the following python statements if there is no error. 1
Otherwise, identify the error(s):

(a) ['0', '2', '0', '2'] # 4


(b) ['r', '2', '0', '2',’0’] # 4
(c) ['2', '0', '2', '0'] # 4
(d) ['2', '0', '2', '0'] # 5
10 Which of the following types of table constraints will prevent the entry of 1
duplicate rows?
a) Check
b) Distinct
c) Primary Key
d) NULL
11 Syntax of seek function in Python is myfile.seek(offset, reference_point) where 1
myfile is the file object. What is the default value of reference_point?
a)2
b) 1
c)0
d) 3
12 Fill in the blanks : 1
____________ statement is used to remove all records of a table “BACKUP”
along with its structure to release the storage space.
a) DELETE TABLE BACKUP;
b) DROP TABLE BACKUP;
c) ALTER TABLE BACKUP;
d) REMOVE TABLE BACKUP;
13 Fill in the blank: 1
______is a program used for sending messages to other computer users based
on e-mail addresses.
(a) IMAP(b) SMTP (c) FTP(d)HTTP

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


print( 6 * 3 + 4**2 // 5 – 8)
(a) 13.2(b)14.0 (c) 13(d) 11

15 Which of the following aggregate function does not ignore nulls in its results? 1

(a) COUNT (b) COUNT(*) (c)MAX( ) (d) MIN( )


16 To run an SQL query from within Python, you may use 1
<cursor_object>.________.
(a) query( ) (b)fetchall( )(c)run() (d) execute( )
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 function can be called with keyword argument. 1


Reasoning: While calling a function with keyword argument parameter
sequence is not mandatory.

18 Assertion (A):The dump( ) method is used to write data in a binary file. 1


Reason (R):To use dump( ) , we must import the csv module .

SECTION-B
19 Saroj has written a Python code . His code is having errors. Rewrite the correct 2
code and underline the corrections made.

def evaluate( ) :
Value=30
for val in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val%5=0:
print (VAL+3)
else
print(VAL+10)

20 Write two points of difference between Circuit Switching and Packet Switching. 2
OR
Write two points of difference between Hackers and Crackers.

21 (a) Given is a Python string declaration: (01) 2

msg = “Hello Friends”

Write the output of: print(msg [ : : -1])


(b) Write the output of the code given below: (01)
pr_dict = {"myname": "Ranjan", "address": “BBSR”}
pr_dict['age'] = 19
pr_dict['address'] = "Cuttack"
print(pr_dict.items())

22 Explain the Candidate Key in a Relational Database Management System. Give 2


an example to support your answer.

23 (a) Write the full forms of the following: 2


(i) IMAP
(ii) VoIP

(b) Which protocol helps us to transfer files to and from a remote computer?

24 Find and write the output of the following python code: 2


Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = " "
Add = 0
for C in range(1,5,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times, Add, Alpha)

“OR”

Predict the output of the Python code given below:


T = (77, 25, 35, 61, 55 ,97)
L =list(T)
N_list = []
for i in L :
if i%2==0:
N_list.append(i)
N_tuple = tuple(N_list)
print(N_tuple)

25 Differentiate between HAVING clause and WHERE clause in MySQL ? 2

“OR”

Categorize the following commands as DDL or DML:

DROP TABLE, SELECT, ALTER TABLE, UPDATE

SECTION-C
26 (a) Consider the following tables – Customer and City: (01) 3
Table: Customer
CID CNAME AMOUNT
1001 Mukesh 5000
1002 Kailash 4500
1003 Nitesh 6000

Table : City

CID CITY
1001 Rourkela
1002 Bhubaneswar
1001 Cuttack
What will be the output of the following statement?
SELECT * FROM Customer NATURAL JOIN City ;
(b)Write the outputs of the SQL queries (i) to (iv) based on the table given below:
(02)

(i) SELECT DISTINCT ANO FROM TRANSACT ;


(ii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT
GROUP BY ANO HAVING COUNT(*)> 1;
(iii) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT
WHERE DOT <= '2017-06-01';
(iv) SELECT AVG(AMOUNT) FROM TRANSACT
WHERE ANO=103;
27 Write a method DISPLAY( ) in Python to read lines from a text file 3
DIARY.TXT, and display those lines, which are starting with an alphabet „P‟.
For example:
“Python is a high level programming language.
It is easy to learn.
Python language uses interpreter.
A language processor is also called a language translator.”
The output should be :
Python is a high level programming language.
Python language uses interpreter.
“OR”
Write a method in python to read lines from a text file INDIA.TXT, to find and
display the occurrence of the word “India”.
For example:
If the content of the file is
_________________________________________________________________
“India is the fastest growing economy. India is looking for more investments
around the globe. The whole world is looking at India as a great market. Most of
the Indians can foresee the heights that India is capable of reaching.”
_________________________________________________________________
The output should be 4

28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
TRAINER and COURSE given below:

i) SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;


ii) SELECT TID, COUNT (*), MAX(FEES) FROM COURSE GROUP BY TID
HAVING COUNT (*)>1;
iii) SELECT T.TNAME, C.CNAME FROM TRAINER T, COURSE C WHERE
T.TID=C.TID AND C.FEES<10000;
iv) SELECT CITY, AVG(SALARY) FROM TRAINER
WHERE CITY=‟DELHI‟;

(b) Write a MySQL command to view the list of all databases.

29 Write a function SHOW_INDEX(Li), where Li is the list of elements passed as 3


argument to the function. The function returns another list named List_indices
that stores the indices of all negativeelements of Li.
For example:
If L contains [-65,4,0,-13 , 88 ,-33, -72]
The List_indices will have - [0,3,5,6]

30 Manoj has a list containing 10 integers. You need to help him create a program 3
with separate user defined functions to perform the following operations based on
this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack.

For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12

“OR”
Julie has created a dictionary containing names and marks as key value pairs of 6
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 (marks) is greater than 75.
● Pop and display the content of the stack.

For example:
If the sample content of the dictionary is as follows:
R={"Niki":76, "Manu":45, "Bilu":89, "Ani":65, "Kanu":90, "Hok":82}
The output from the program should be:
NikiBiluKanuHok
SECTION-D
31 5
Intelligent Hub India is a knowledge community aimed to uplift the standard
of skills and knowledge in the society. It is planning to setup its training
centers in multiple towns and villages pan India with its head offices in the
nearest cities. They have created a model of their network with a city, a town
and 3 villages as given.
As a network consultant, you have to suggest the best network related solution
for their issues/problems raised in (i) to (v) keeping in mind the distance
between various locations and given parameters.
Shortest distance between various locations:

Number of computers installed at various locations are as follows:

Note:
• In Villages, there are community centers, in which one room has been given
as training center to this organization to install computers.
• The organization has got financial support from the government and top IT
companies.

I. Suggest the most appropriate location of the SERVER in the YHUB


(out of the 4 locations), to get the best and effective connectivity.
Justify your answer.
II. Draw the cable layout (location to location) to efficiently connect
various locations within the YHUB.
III. Which hardware device will you suggest connecting all the computers
within each location of YHUB?
IV. Which server/protocol will be most helpful to conduct live
interaction of Experts from Head office and people at YHUB
locations?
V. Suggest the best wired medium to efficiently connect various
locations within the YHUB

32 (a) Predict the output of the Python code given below: (02) 2+3=
5
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
(b) The code given below inserts the following record in the table Employee:
EmpNo – integer (03)
EmpName – string
EmpDesig – string
EmpSalary – float
Note the following to establish connectivity between Python and MYSQL:
 Username is „root‟
 Host name is „localhost‟
 Password is „dav@123‟
 The table exists in a MYSQL database named STORE.
 The details (EmpNo, EmpName, EmpDesig,EmpSalary) are to be accepted
from the user.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Employee.
Statement 3- to add the record permanently in the table Employee.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="dav@123",
database="STORE")
mycursor=_________________ #Statement 1
EmpNo=int(input("Enter Employee Number :: "))
EmpName=input("Enter name :: ")
EmpDesg=input("Enter employee designation :: ")
EmpSalary=float(input("Enter Salary :: "))
querry="insert into student values({},'{}',‟{}‟,{})".
format (EmpNo,EmpName,EmpDesig,EmpSalary)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")

“OR”

(a) Find and write the output of the following python code: (02)
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print (Msg3)

(b) Meena wants to see all the records from the Traders table. (03)
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 .
Statement 3 – to read the complete result of the query .

import mysql.connector as db
mycon=db.connect(host=”localhost”,user=”system”,password=”test”,datab
ase=”Admin”)
cursor=___________________# statement 1
sql=”SELECT * FROM Traders “
______________________ # Statement 2
data=__________________ # Statement 3
for dt in data:
print(dt)
mycon.close()

33 What is the advantage of using a csv file for permanent storage? 5


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

a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode


containing information of books – Title, Author and Price.

b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field title starts with 'R'.
“OR”
Give any one point of difference between a binary file and a text file.
Write a Program in Python that defines and calls the following user defined
functions:

a) ADD_DATA() – To accept and add data of an employee to a CSV file


„items.csv‟. Each record consists of a list with field elements as id, iname and
iprice to store item id, item name and item price respectively.

b) SEARCH()- To display the records of the items whose price is more than
25000.

SECTION-E
34 1+1+
2
=4
(c) and answer the questions (a) and (b)

(a) Identify the attribute best suitable to be declared as a primary key.


(b) Write the degree and cardinality of the Table GRADUATE.
(c) (i) To increase the stipend of PHYSICS students by 100.
(ii) Display the name of those students whose name starts with „D‟.
“OR”
(i) Display the details of all students who secured an average below 40.
(ii) Display the name of those students whose name ends with „A‟.
35 Amritya Seth is a programmer, who has recently been given a task to write a 1+1+
python code to perform the following binary file operations with the help of two 2
user defined functions/modules: =4
a. AddStudents() to create a binary file called STUDENT.DAT containing
student information – roll number, name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who
have a percentage greater than 75. In case there is no student having percentage >
75 the function displays an appropriate message. The function should also display
the average percent.

He has succeeded in writing partial code and has missed out certain statements,
so he has left certain queries in comment lines. You as an expert of Python have
to provide the missing statements and other related queries based on the
following code of Amritya.
Answer the below mentioned questions.
import _______________ # Statement 1
def AddStudents():
____________ # Statement 2 to open the binary file to write data
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
____________ # Statement 3 to write the list L into the file
Choice = input("enter more (y/n): ")
if Choice in "nN":
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open("STUDENT.DAT","rb") as F:
while True:
try:
____________ # Statement 4 to read from the file
Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], " has percent = ",R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print("There is no student who has percentage more than 75")
average=Total/Countrec
print("average percent of class = ",average)
AddStudents()
GetStudents()

(i) Which module should be imported in the program? (Statement 1)


(ii) Which command is used to open the file “STUDENT.DAT” for writing
only in binary format? (marked as # Statement 2 in the Python code)
(iii)(a) Which command is used to write the list L into the binary file,
STUDENT.DAT? (marked as # Statement 3 in the Python code)
(b) Which command is used to read each record from the binary file
STUDENT.DAT? (marked as # Statement 4 in the Python code)

*******
SAMPLE QUESTION PAPER 2022-23
CLASS- XII
Time: 3 hrs COMPUTER SCIENCE (083) Max. Marks: 70
Marking Scheme – 8
SECTION-A
01 (i) if- Keyword (ii) roll_no– Identifier (1/2 mark for each correct answer) 1
02 (d) and 1
03 b) T[2] = –96 1
04 (a) True 1
05 (b) Python. . .0 Programming Language. 1
06 c. myfile = open('Myfile.txt'); myfile.readline() 1
07 (b) show tables 1
08 d) DDL 1
09 (c) ['2', '0', '2', '0'] # 4 1
10 c) Primary Key 1
11 c)0 1
12 b) DROP TABLE BACKUP; 1
13 (b) SMTP 1
14 (c) 13 1
15 (b)COUNT(*) 1
16 (d)execute( ) 1
17 (a) Both A and R are true and R is the correct explanation for A 1
18 (c) A is True but R is False 1
SECTION-B
19 def evaluate( ) : 2
Value=30
for val in range(0,Value):
if val%4==0:
print (VAL*4)
elif val%5= =0:
print (VAL+3)
else :
print(VAL+10)
(½ mark for each correct correction made and underlined.)

20 MESSAGE SWITCHING PACKET SWITCHING 2


A complete message is passed across a Message is broken into smaller units
network. known as Packets.
In message switching there is no limit Packet switching places a tight upper
on block size. limit on block size.
Message exist only in one location in Parts i.e. packets of the message exist in
the network. many places in the network.
( 1 mark for each correct point of difference)

OR
2
(1 mark for each correct difference - Any two)
21 (a) 'sdneirFolleH' 2
(b)dict_items([('myname', 'Ranjan'), ('age', 19), ('address', 'Cuttack')])

22 A Candidate Key can be any column or a combination of columns that can qualify as 2
unique key in database. There can be multiple Candidate Keys in one table.
Example :
SID ADMNO NAME CLASS MARKS
S001 1001 Anil Kumar XI 480
S002 1002 Akash Dash XII 350
S003 1003 Nitesh Singh XI 280
S004 1004 Pari Thakur XII 350
S005 1005 Nitesh Singh XII 410

Here, SID &ADMNO are the Candidate keys.


(1 mark for explanation and 1 mark for example)

23 (a) (i) IMAP- Internet Mail Access Protocol 2


(ii) VoIP- Voice over Internet Protocol
(½ mark for every correct full form)
(b) FTP OR Telnet OR TCP
(1 mark for correct answer)

24 OUTPUT: 1 20 P$ 2
4 30 P$R$
“OR”
OUTPUT:(25, 35, 55)
25 The HAVING Clause enables you to specify conditions that filter which group 2
results appear in the results. The WHERE clause places conditions on the selected
columns, whereas the HAVING clause places conditions on groups created by the
GROUP BY clause.

“OR”
DROP TABLE, ALTERTABLE : DDL Commands
SELECT , UPDATE : DML Commands

SECTION-C
26 (a) 3
CID CNAME AMOUNT CITY
1001 Mukesh 5000 Rourkela
1001 Mukesh 5000 Cuttack
1002 Kailash 4500 Bhubaneswar

(1 mark for correct output)


(b) i) DISTINCT ANO
101
102
103
ii) ANO COUNT(*) MIN(AMOUNT)
101 2 2500
103 2 1000
iii) COUNT(*) SUM(AMOUNT)
2 5000
(iv) AVG(AMOUNT)
2000
(1/2 mark for each correct output)
27 def DISPLAY(): 3
file=open('DIARY.TXT','r')
line=file.readline()
while line:
if line[0]=='P' :
print( line)
line=file.readline()
file.close() #IGNORE
(½ Mark for opening the file)
(½ Mark for reading all lines)
(½ Mark for checking condition for line starting with P)
(½ Mark for displaying line)
“OR”
def display():
c=0
file=open('INDIA.TXT','r')
lines = file.read() # lines = file.readline()
while lines:
words = lines.split()
for w in words:
if w=="India":
c=c+1
lines = file.read() # lines = file.readline()
print (c)
file.close()
(½ mark for correctly opening and closing the file
½ for readlines()
½ mark for correct loops
½ for correct if statement
½ mark for correctly incrementing counts
½ mark for displaying the correct output)
28 (a) 3
OUTPUT
i) MUMBAI
CHANDIGARH
ii) TID COUNT(*) MAX(FEES)
101 2 20000
iii) T.TNAMEC.CNAME
MEENAKSHI DDTP
iv) CITY AVG(SALARY)
DELHI 79000
(1/2 mark for each correct output)
(b) SHOW DATABASES;
29 def SHOW_INDEX(Li): 3
List_indices=[]
for i in range(len(Li)):
if Li[i]<0:
List_indices.append(i)
return List_indices
(½ mark for correct function header
1 mark for correct loop
1 mark for correct if statement
½ mark for return statement)
30 N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38] 3
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in N:
if k%2==0:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break

“OR”
R={"Niki":76, "Manu":45, "Bilu":89, "Ani":65, "Kanu":90, "Hok":82}

def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None
ST=[]
for k in R:
if R[k]>=75:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
SECTION-D
31 (i) YTOWN, as it has maximum number of computers. 5
(1/2 mark for naming the server block and ½ mark for correct reason.)

(ii) 1 mark for correct layout.

(iii) SWITCH
(1 mark for the correct answer)
(iv) VoIP
(1 mark for the correct answer)
(v) Optical Fibre
(1 mark for the correct answer)
32 (a) 22 # 40 # 9 # 13 # 2
(b) Statement 1: +
con1.cursor() 3
Statement 2: =
mycursor.execute(querry) 5
Statement 3:
con1.commit()
(1 mark for each correct answer)
“OR”
(a) G*L*TME
(b) Statement 1 :mycon.cursor( )
Statement 2 :cursor.execute(sql)
Statement 3 :cursor.fetchall( )
33 Advantage of a csv file: 5
 It is human readable – can be opened in Excel and Notepad applications
 It is just like text file where the date is stored in ASCII code format.
Program :
import csv
def CSVOpen():
with open('books.csv','a',newline='') as csvf:
cw=csv.writer(csvf)

cw.writerow(['Title','Author','Price'])
cw.writerow(['Rapunzel','Jack',300])
cw.writerow(['Barbie','Doll',900])
cw.writerow(['Johnny','Jane',280])
def CSVRead():
try:
with open('books.csv','r') as csvf:
cr=csv.reader(csvf)
for r in cr:
if csv.reader(csvf) :
print(r)
except:
print('File Not Found')
CSVOpen()
CSVRead()
(1 mark for advantage
½ mark for importing csv module
1 ½ marks each for correct definition of CSVOpen() and CSVRead()
½ mark for each function call statements )
“OR”
Difference between binary file and text file: (Any one difference may be given)
Binary file:
 Extension is .dat
 Not human readable
 Stores data in the form of 0s and 1s

Text file
Extension is .txt
 Human readable
 Stores data in ASCII code format

Program:
import csv
def ADD_DATA():
fout=open("items.csv","a",newline='\n')
wr=csv.writer(fout)
id=int(input("Enter Item Id :: "))
iname=input("Enter Item name :: ")
iprice=int(input("Enter Item price :: "))
DATA=[id,iname,iprice]
wr.writerow(DATA)
fout.close()
def SEARCH():
fin=open("items.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])>25000:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
add()
print("Now displaying")
search()
(1 mark for difference
½ mark for importing csv module
1 ½ marks each for correct definition of ADD_DATA() and SEARCH()
½ mark for function call statements )
SECTION-E
34 (a) ROLLNO 4
(b) Degree=6 ; Cardinality=10
( 1 mark each)
(c) (i) UPDATE GRADUATE
SET STIPEND=STIPEND+100;
(ii) SELECT NAME FROM GRADUATE
WHERE NAME LIKE „D%‟;
“OR”
(i) SELECT * FROM GRADUATE
WHERE AVERAGE<40;
(ii) SELECT NAME FROM GRADUATE
WHERE NAME LIKE „%A‟;

35 i) pickle (01) 4
ii) F= open("STUDENT.DAT",'wb')(01)
iii) (a) pickle.dump(L,F) (02)
(b) R = pickle.load(F)

****************
SAMPLE QUESTION PAPER – 9 (2022-23)
CLASS- XII
COMPUTER SCIENCE (083)
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 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 c only.
8. All programming questions are to be answered using Python Language only.

SECTION A
Q,1 Tell whether the statement is True or False : 1
“The python language supports Unicode encoding standards “
Q.2 Identify what is correct data type of x if x = True? 1
(a) Dictionary
(b)String
(c) Boolean
(d)None of the above
Q.3 Which of the following is not a declaration of the dictionary? 1
(a) {1: „A‟, 2: „B‟}
(b) dict([[1,”A”],[2,”B”]])
(c ) {1,”A”,2”B”}
(d) { }
Q.4 Consider the given expression: 1
True and False or True not
Which of the following will be correct output if the given expression
is evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Q.5 Select the correct output of the code: 1
>>> a = "Offline class 2022, All the best"
>>> a = a.split(' ')

SAMPLE QP / COMP.SC. -XII Page 1 of 11


>>> b = a[0] + ". " + a[1] + ". " + a[2] + a[3]
>>> print (b)
(a) Offline . class. 2022, All the best
(b) Offlineclass2022Allthebest
(c) Offline . class. 2022 All the best
(d) Offline . class. 2022,All

Q.6 For both Reading and writing in a File which does not exist which of 1
the mode should be used:
(a) w
(b) r
(c) w+
(d) r+
Q.7 Fill in the blanks: 1
________ keyword is used to eliminate the duplicates from the query
result.
(a) Unique (b) Union (c ) Different (d) DISTINCT
Q.8 Which clause is used to sort the query result ? 1
(a)Order by (b) Sort by (c) Group by (d)Arrange by
Q.9 Which one of the following if statements will not execute 1
successfully?
1. if (1, 2) ;
print('foo')
2. if (1, 2) :
print('foo')
3. if (1) :
print( 'foo' )
4. if (1) ;
print( 'foo' )

(a) 1 ,4 (b)2 (c) 2,4 (d) 4


Q.10 In the relational models, relationships among relations/tables are 1
created by using ______________ key.
(a) composite (b) alternate (c ) candidate (d) foreign
Q.11 The correct syntax of seek() is: 1
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
Q.12 Fill in the blank: 1
The __________ clause of SELECT query allows us to select only
those rows in the result that satisfy a specified condition.
(a) where (b) from (c) having (d)like

SAMPLE QP / COMP.SC. -XII Page 2 of 11


Q.13 Fill in the blank: 1
________is the following protocol ensures safe transmission of data ?
(a) FTP (b) GDP (c) HTTP (d) HTTPS
Q.14 What will be output of following expression: 1
(5<10) AND (10<5) OR (3<18) AND NOT 8<18
(a) Error (b) True (c) False (d) None of these
Q.15 Which built in function is used to find the totals values in numeric 1
columns?
(a) sum(*) (b) total(*) (c) count(*) (d) return(*)

Q.16 To open a connector to MYSQL database, which statement is used to 1


connect with MYSQL ?
(a) connector (b) connect (c ) password (d) username
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a) A is true but R is false
(b) A is true but R is not correct explanation of A
(c) A and B both are false
(d)A is false and R is correct
Q.17 (A) Assertion str1=”Hello” and str1=”World” then print(str1*3) 1
will give error
(R) Reason : * replicates the string hence correct output will be
HelloHelloHello
(a) A is true but R is false
(b) A is true but R is not correct explanation of A
(c) A and B both are false
(d) A is false and R is correct
Q.18 (A) Assertion str1=”Hello” and str1=”World” then print(„wo‟ not in 1
str) will print false
(R) Reason : not in returns true if a particular substring is not present
in the specified string.
(a) A is true but R is false
(b) A is true and R is correct explanation of A
(c) A and B both are false
(d)A is true but R is not correct explanation of A
SECTION B
Q.19 Observe the following Python code very carefully and rewrite it after 2
removing all syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)= x)

SAMPLE QP / COMP.SC. -XII Page 3 of 11


print("You entered a positive number")
else:
x=*-1
print("Number made positive:"x )
Q.20 What is circuit switching? Define packet switching 2
OR
When do you prefer XML over HTML and why?
Q.21 (a)What will be the output ? 2
name="Computer_Science_with_Python"
print(name[-25:10])
(b) What will be the output ?
dic={'a':1,'b':2,'c':3,'d':4}
print(dic)
if 'a' in dic:
del dic['a']
print(dic)
Q.22 Difference between Primary Key and Foreign Key? 2

Q.23 (a) Expand the following terms: 1 2


(a) IPR (b) IMAP
(b) Differentiate between Web server and Web browser.
1
Q.24 Predict the output of the Python code given below: 2
def fun(s):
n = len(s)
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
fun('Gini%Jony')
OR
Predict the output of the Python code given below:

frequency = { }
list = ['a','b','c','a','c']
for index in list:

SAMPLE QP / COMP.SC. -XII Page 4 of 11


if index in frequency:
frequency[index]+=1
else:
frequency[index]=1

print(len(frequency))
print(frequency)
Q.25 What is the difference between CHAR & VARCHAR data types in 2
SQL? Give an example for each.
OR
Categorize the following as DML and DDL Commands:
SELECT, INSERT, CREATE, UPDATE, ALTER, DELETE, DROP
SECTION C
Q.26 (a) Give one point of difference between an equi-join and a natural 1+2
join.
(b) Write a output for SQL queries (i) to (iv), which are based on the
table: COURSE given below:

(i) SELECT DISTINCT TID FROM COURSE;


(ii) SELECT TID, COUNT(*), MIN(FEES) FROM COURSE
GROUP BY TID HAVING COUNT(*)>1;
(iii)SELECT SUM(FEES) FROM COURSE WHERE STARTDATE<
„2018-09-15‟;
(iv) SELECT MIN (FEES) FROM COURSE
Q.27 Write a method COUNTWORDS() in Python to read lines from text 3
file „TESTFILE.TXT‟ and Count the number of words in a file
OR
Write a method FINDWORD() in Python to read lines from text file
„FILE.TXT‟ and Count the number of „is‟ word in a text file.
Q.28 (a) Write SQL commands for the following queries (i) to (iv) 3
based on the relations TRAINER & COURSE given below:

SAMPLE QP / COMP.SC. -XII Page 5 of 11


(i) Display all details of Trainers who are living in city CHENNAI.
(ii) Display the Trainer Name, City & Salary in descending order of
their Hiredate.
(iii) Display the Course details which have Fees more than 12000
and name ends with„A‟.
(iv) Display the Trainer Name & Course Name from both tables
where Course Fees is less than 10000.
(b) What is the use of LIKE keyword in SQL?
Q.29 Write a function LShift(Arr,n) in Python, which accepts a list Arr of 3
numbers and n is a numeric value by which all elements of the list are
shifted to left.
Sample Input Data of the list
Arr= [ 10,20,30,40,12,11], n=2
Output
Arr = [30,40,12,11,10,20]
Q.30 Write a function in Python PUSH(Arr), where Arr is a list of numbers. 3
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 display appropriate error message.
OR
Write a function in Python POP(Arr), where Arr is a stack
implemented by a list of numbers. The function returns the value
deleted from the stack.
SECTION D
Q31 Hi Standard Tech Training Ltd is a Mumbai based organization which
is expanding its office set-up to Chennai. At Chennai office
compound, they are planning to have 3 different blocks for Admin,
Training and Accounts related activities. Each block has a number of
computers, which are required to be connected in a network for
SAMPLE QP / COMP.SC. -XII Page 6 of 11
communication, data and resource sharing.As a network consultant,
you have to suggest the best network related solutions for them for
issues/problems raised by them in (a) to (e), as per the distances
between various blocks/locations and other given parameters

(a) Suggest the most appropriate block/location to house the


SERVER in the CHENNAI Office (out of the 3 blocks) to get 1
the best and effective connectivity. Justify your answer.
(b) Suggest the best wired medium and draw the cable layout
(Block to Block) to efficiently connect various blocks within 1
the CHENNAI office compound.
(c) Suggest a device/software and its placement that would
provide data security for the entire network of the Chennai 1
office.
(d) Which device will you suggest to be placed/installed in each
of these blocks/offices to efficiently connect all the computers 1
within these blocks/offices?
(e ) Suggest the placement of Repeater device.
1
Q.32 (a) What will be the output of the following Python code? 2+3
def power(x, y=2):
r=1
for i in range(y):
r=r*x
return r

SAMPLE QP / COMP.SC. -XII Page 7 of 11


print(power(3))
print(power(3, 3))
(b) The code given below inserts the following record in the
table Student:
Name – string
Gender – string
DOB – date
Stream- string
Marks – integer
Note the following to establish connectivity between Python
and MYSQL:
 Username is root
 Password is 123
 The table exists in a MYSQL database named school.
 The details ( Name,Gender,DOB,Stream and Marks) are
to be accepted from the user.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in
the table Student.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",
password="123", database="school")
mycursor=_________________ #Statement 1
Name=input("Enter name :: ")
Gender=(input("Enter Gender :: "))
DOB= (input("Enter Gender :: "))
Stream=(input("Enter Stream :: "))
Marks=int(input("Enter Marks :: "))
querry="insert into student values(„{}‟,'{}',‟{}‟,
‟{}‟,{})".format(Name,Gender ,DOB,Stream,Marks)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()

SAMPLE QP / COMP.SC. -XII Page 8 of 11


else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('CBSE@Term1#Exam')
(b) The code given below inserts the following record in the table
Student:
Name – string
Gender – string
DOB – date
Stream- string
Marks – integer
Note the following to establish connectivity between Python and
MYSQL:
 Username is root
 Password is 123
 The table exists in a MYSQL database named school.
 The details ( Name,Gender,DOB,Stream and Marks) are to be
accepted from the user.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the querythat extract records of those
student whose marks are greater than 90
Statement 3- to read the complete result of the query (records whose
marks are greater than 90) into the object named data, from the table
student in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",password="123",
database="school")
mycursor=_______________ #Statement 1
print("Students with marks greater than 90 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()

Q.33 Write the function of reader object in a csv file. 5


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

SAMPLE QP / COMP.SC. -XII Page 9 of 11


(a) Write() - To input and add data of a student into a csv file
named „Record.csv‟ . Each student record consists of a list with
held elements as roll, name, and aggregate to store roll number ,
student name and aggregate marks respectively.
(b) Count() – To count and display the number of student records
with aggregate marks more than 75,present in the csv file
named „Record.csv‟.
OR
Give any one point of difference between a binary file and a csv file,
Write a program in python that defines and calls the following user
defined function:
(a) Add() – To input and add data of a book to a csv file named
„Book.csv‟. Each record consists of a list with filled elements
as bookid, bookname and bookprice to store book id, book
name , and book price respectively.
(b) Search() – To display records of all books.
SECTION D
Q.34 A CD/DVD Shop named “NEW DIGITAL SHOP” stores 1+1+2
various CDs & DVDs of songs/albums/movies and use SQL to
maintain its records. Now needs to create a table named LIBRARY
in the database to store the records of various CDS &DVD. The table
LIBRARY has the following structure:
Table:
LIBRARY
CDNO NAME QTY PRICE
10001 Indian Patriotic 20 150
10004 Hanuman Chalisa 15 80
10005 Instrumental of Kishore 25 95
10003 Songs of Diwali 18 125
10006 Devotional Krishna Songs 14 75
10002 Best Birthday Songs 17 NULL
(i) To complete the task by suggesting appropriate SQL commands.
(ii) Identify the most appropriate column, which can be considered as
Primary key.
(iii) Write the statements to:
a. Insert the following record into the table – CDNO- 10008,
Name-ARMAN,QTY- 470, PRICE-200.
b. Increase the PRICE by 3% whose name begins with „D‟.
OR (Option for Part iii only)
iii. Write the statements to:
a. Delete the record of Library PRICE >100.
b. Add a column REMARKS in the table with datatype as varchar
with 50 characters
35 Rishi is a Python programmer. He has written a code and created a
binary file record.dat with employeeid, ename and salary. The file
contains 10 records. He now has to update a record based on the
SAMPLE QP / COMP.SC. -XII Page 10 of 11
employee id entered by the user and update the salary. The updated
record is then to be written in the file temp.dat. The records which are
not to be updated also have to be written to the file temp.dat. If the
employee id is not found, an appropriate message should to be
displayed. As a Python expert, help him to complete the following
code based on the requirement given above:

import _______ #Statement 1


def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found=False
eid=int(input("Enter employee id to update their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a temporary file 1
named temp.dat. (Statement 2) 1
(iii) Which statement should Rishi fill in Statement 3 to read the data
2
from the binary file, record.dat and in Statement 4 to write the
updated data in the file, temp.dat?
****

SAMPLE QP / COMP.SC. -XII Page 11 of 11


SAMPLE QUESTION PAPER (2022-23)
CLASS- XII
SUB:COMPUTER SCIENCE (083)
MARKING SCHEME - 9
QSTN
NO
Value Points Marks Allotted

1 True 1
2 (c ) Boolean 1
3 (c) {1,”A”,2”B”} 1
4 (b) False 1
5 (d) Offline . class. 2022,All 1
6 (c) w+ 1
7 (d) DISTINCT 1
8 (a)Order by 1
9 (b) 2 1
10 (d) foreign 1
11 Ans: (a) file_object.seek(offset [, reference_point]) 1
12 (a) where 1
13 (d) HTTPS 1
14 (c) False 1
15 (a) sum(*) 1
16 (b) connect 1
17. (d) A is false and R is correct 1
18. (b)A is true but R is not correct explanation of A 1

19 def execmain(): 2
x = input("Enter a number:")
if (abs(x)== x):
print("You entered a positive number")
else:
x*=-1
print("Number made positive:",x )
(½ mark for each error correction)

20 Circuit Switching:Dedicated Path for duration of 2


Communication, Physical switched must me closed,
Transmission via Intermediate node, For Telephonic
communication
Packet Switching: Message divided into packets and routed
through the different path. Each packet takes the different path
to reach the destination end. When packets are received by the
destination station. They are reassembled.
(0.5 marks for each correct explanation.)
OR
The first benefit of XML is that because you are writing your
own markup language, you are not restricted to a limited set of
tags defined by proprietary vendors. Rather than waiting for
standards bodies to adopt tag set enhancements (a process
which can take quite some time), or for browser companies to
adopt each other's standards, with XML, you can create your
own set of tags at your own pace.
(1 marks for each correct explanation.)
21 (a) puter_S 1
(1 mark for the correct answer)

(b) {'a': 1, 'b': 2, 'c': 3, 'd': 4} 1


{'b': 2, 'c': 3, 'd': 4}
0.5 marks for each line output)
22 Primary Key: 2
A primary key is used to ensure data in the specific column is
unique. It is a column cannot have NULL values. It is either an
existing table column or a column that is specifically
generated by the database according to a defined sequence.
A foreign key is a column or group of columns in a
relational database table that provides a link between data
in two tables. It is a column (or columns) that references a
column (most often the primary key) of another table.
(1 marks for each correct explanation.)
23 (a) (i) IPR – Intellectual Property Rights 2
(ii) IMAP – Internet Message Access Protocol
(½ mark for every correct full form)
(c )Web Browser : A web browser is a software
application for accessing information on the World
Wide Web. When a user requests a web page from a
particular website, the web browser retrieves the
necessary content from a web server and then
displays the page on the user's device. Web Server :
A web server is a computer that runs websites. The
basic objective of the web server is to store, process
and deliver web pages to the users. This
intercommunication is done using Hypertext Transfer
Protocol (HTTP). Popular web browsers : Google
Chrome, Mozilla Firefox, Internet Explorer etc
(1 mark for each correct answer.)
24 gIiI#jJon 2
1 mark for each4 letters , deduct ½ mark for # sign.
OR
3
{'a': 2, 'b': 1, 'c': 2}
(1 mark for each line correct output)
25 CHAR is used to occupy fixed memory irrespective of the 2
actual values but VARCHAR uses only that much memory
which is used actually for the entered values.
VARCHAR will uses only that much bytes of memory
whose values are passed.
(0.5 mark for each correct answer)
OR
DDL – Create, Alter, Drop
DML- Select, Insert, Update, Delete
(½ mark for each correct categorization)
26 (a) Equi- join: The join in which columns from two tables are 1+2
compared for equality and duplicate columns are shown
Natural Join : The join in which only one of
the identical columns existing in both tables is
present and no duplication of columns
(0.5 mark for correct difference (Any one point may be
given))
(b) (i) DISTINCT TID
101
103
102
104
105
(ii) TID COUNT(*) MIN(FEES)
101 2 12000

(iii) SUM(FEES)
65000
(iv ) MIN(FEES)
9000
(0.5 mark for each correct Answer)

27 fin=open("TESTFILE.TXT ",'r') 3
str=fin.read()
L=str.split()
count_words=0
for i in L:
count_words=count_words+1
print(count_words)
fin.close( )
½ mark for correctly opening and closing the file
½ for readlines()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
OR
fin=open("D:\\python programs\\ FILE.TXT t",'r')
str=fin.read()
L=str.split()
count=0
for i in L:
if i=='is':
count=count+1
print(count)
fin.close( )

½ mark for correctly opening and closing the file


½ for readlines()
½ mar for correct loop
½ for correct if statement
½ mark for correctly incrementing count
½ mark for displaying the correct output)
Note: Any other relevant and correct code may be marked
28 (a) 3
(i) SELECT * FROM TRAINER WHERE CITY IS
“CHENNAI”;
(ii) SELECTTNAME,CITY,SALARY FROM
TRAINER ORDER BY HIREDATE DESC;
(iii)SELECT * FROM COURSE WHERE
FEES>12000 AND CNAME LIKE „%A‟;
(iv) SELECT T.TNAME, C.CNAME FROM
TRAINER T, COURSE C WHERE
T.TID=C.CID AND C.FEES<10000;
(0.5 mark for each correct answer.)
(b) LIKE keyword is used to find matching CHAR
values with WHEREclause.
(1 mark for correct answer.)

29 def LShift(Arr,n): 3
L=len(Arr)
for x in range(0,n):
y=Arr[0]
for i in range(0,L-1):
Arr[i]=Arr[i+1]
Arr[L-1]=y
print(Arr)
Note : Using of any correct code giving the same result is also
accepted.
30 ANSWER: (Using of any correct code giving the same result 3
is also accepted.)
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)
OR
def popStack(st) :
# If stack is empty
if len(st)==0:
print("Underflow")
else:
L = len(st)
val=st[L-1]
print(val)
st.pop(L-1)
31 a)Training Block - Because it has maximum number of 1
computers.
(½ Mark for correct Block/location)
(½ Mark for valid justification)
b) Best wired medium: Optical Fiber OR CAT5 OR CAT6 OR 1
CAT7 OR CAT8 OR Ethernet Cable

(½ Mark for writing best wired medium) (½ Mark for


drawing the layout correctly)
c) Firewall - Placed with the server at the Training Block OR 1
Any other valid device/software name.

(½ Mark for writing device/software name correctly) (½


Mark for writing correct placement)
d) Switch/Hub 1
(1 Mark for writing device name correctly)
e) All blocks
(1 Mark fpr placement of repeater correctly) 1
32 (a) 9 2+3
27
(b)Statement 1:
con1.cursor()
Statement 2:
mycursor.execute(querry)
Statement 3:
con1.commit()
(1 mark for each correct answer)
OR
(a) cbseEtERM#1eXAM
(b) Statement 1:
con1.cursor()
Statement 2:
mycursor.execute("select * from student where Marks>75")
Statement 3:
mycursor.fetchall()
33 Ans: 5
(a) The reader object reads data from a csv file on storage disk
and removes the delimiter and loads the data into a python
iterator from ehich the data can be fetched row by row
Program:
import csv
def Write():
fout=open("record.csv","a",newline="\n")
wr=csv.writer(fout)
roll=int(input("Enter Employee id :: "))
name=input("Enter name :: ")
aggregate=int(input("Enter aggregate :: "))
lst=[roll,name,aggregate] ---------1/2 mark
wr.writerow(lst) ---------1/2 mark
fout.close()

def Count():
fin=open("record.csv","r",newline="\n")
data=csv.reader(fin)
ctr=0
for I in data:
if i[2]>75:
ctr=ctr+1

print(len(d))
fin.close()
Write()
Count()
(1 mark for advantage
½ mark for importing csv module
1 ½ marks each for correct definition of ADD() and
COUNTR()
½ mark for function call statements )
Ans:
Difference between binary file and csv file: (Any one
difference may be given)
Binary file:
 Extension is .dat
 Not human readable
 Stores data in the form of 0s and 1s
 Requires to import pickle module
CSV file
 Extension is .csv
 Human readable
 Stores data like a text file
 Requires to import csv module
Program:
import csv
def Add():
fout=open("Book.csv","a",newline='\n')
wr=csv.writer(fout)
bid=int(input("Enter Book Id :: "))
bname=input("Enter Book name :: ")
bprice=int(input("Enter Book price :: "))
BD=[fid,fname,fprice]
wr.writerow(BD)
fout.close()
def Search():
fin=open("furdata.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
print(i)
fin.close()

Add()

Search()
(1 mark for difference
½ mark for importing csv module
1 ½ marks each for correct definition of add() and search()
½ mark for function call statements )
34 (i) CREATE DATABASE CDSHOP; 1+1+2
(
CREATE TABLE LIBRARTY ( CDNO INT(5)PRIMARY
KEY , NAME CHAR(25), SQT INT, PRICE(4,2)
);
1 mark for correctly creating database.
(ii)CDNO
1 mark for identify primary key
a. (iii)(a) insert into Library values( 10008, „ARMAN‟,
470, 200)

b. UPDATE LIBRARY SET PRICE=PRICE+ 0.03


WHERE NAME LIKE “D%”;
(1 mark for each correct statement)
OR
a. DELETE FROM LIBRARY WHERE PRICE>100;
b. ALTER TABLE LIBRARY ADD (REMARKS
VARCHAR(50));
(1 mark for each correct statement)
35 (i) Ans: pickle 1
(1 mark for correct module)
(ii)Ans: fout=open(„temp.dat‟, „wb‟) 1
(1 mark for correct statement)
(iii) Statement 3: pickle.load(fin) 2
Statement 4: pickle.dump(rec,fout)
(1 mark for each correct statement)

***
SAMPLE QUESTION PAPER - 10
CLASS: XII
Session : 2022-23
COMPUTER SCIENCE(083)

Maximum Marks :70 Time Allowed: 3 Hours


General Instructions :
1. Thisquestionpapercontainsfivesections,SectionAtoE.
2. Allquestionsarecompulsory.
3. SectionAhave18questionscarrying01markeach.
4. SectionBhas07VeryShortAnswertypequestionscarrying02markseach.
5. SectionChas05ShortAnswertypequestionscarrying03markseach.
6. SectionDhas03LongAnswertypequestionscarrying05markseach.
7. SectionEhas02questionscarrying04markseach.Oneinternalchoiceisgiveni
n Q35against partc only.
8. AllprogrammingquestionsaretobeansweredusingPythonLanguageonly.

SECTION- A
1. State True orFalse . 1
„ In Python , only if statement has else clause‟ .
2. In which data type does input() function return value ? 1
(a)float (b)int (c)string (d)boolean
3. What will be the output of the following Python code ? 1
dic1={'A':15,'B':16,'C':17}
print(dic1[1])
a)B(b) 16 (c) { 'B ':16}(d) Error
4. Find out the valid identifier from the following 1
(a) Student Name b) 3Number c) perc% d) DAV_CMC

CS-SQP-2022 Page 1 of 12
5. What will be the output of the following code? 1
print(“ComputerScience”.split(“er”,2))
a. [“Computer”,”Science”] b. [“Comput”,”Science”]
c.[“Comput”,”erScience”] d. [“Comput”,”er”,”Science”]
6. What is the prefix r stands for in file path? 1
a. raw string b. read c. read mode d. None of these
7 Which clause is used with “aggregate functions”? 1
(a) GROUP BY (b) SELECT (c) WHERE (d) Both (a) and (b)
8 1
Which operator performs pattern matching?
(a) BETWEEN operator (b) LIKE operator
(c) EXISTS operator (d) None of these
9 Whichofthefollowingstatement(s)wouldgiveanerrorafterexecutingthe 1
followingcode?

List1=[1,2,3,4,5]#Statement1
str1='6'#Statement2
for i in List1:#Statement3
str1=str1+ i #Statement4
print(str1)#Statement5

(a) Statement1 (b) Statement 2


(c)Statement3 (d)Statement 4
10 Fill in the blank: 1
A candidate key that is not primary key is called __________.
(a) Primary Key (b) Foreign Key
(c) Alternate Key (d) Candidate Key
11 In regards to separated value files such as .csv and .tsv, what is 1
the delimiter?
(a) Any character such as the comma (,) or tab (\t) that is used
to separate the column data.
(b) Delimiters are not used in separated value files
(c) Anywhere the comma (,) character is used in the file
(d) Any character such as the comma (,) or tab (\t) that is used
to separate the row data
12 With SQL, how do you select all the records from a table named 1
“Students” where the value of the column “FirstName” ends with
an “a”?
(a) SELECT * FROM Students WHERE FirstName =‟a‟ ;
CS-SQP-2022 Page 2 of 12
(b) SELECT * FROM Students WHERE FirstName LIKE „a%‟ ;
(c) SELECT * FROM Students WHERE FirstName LIKE „%a‟ ;
(d) SELECT * FROM Students WHERE FirstName =‟%a%‟;

13 A device that forwards data packet from one network to another is called 1
a _______
(a) Bridge (b) Router (c) Hub (d) Gateway
14 WhatwillthefollowingexpressionbeevaluatedtoinPython? 1
a,b,c=1,2,3
print(a//b**c+a-c*a)
(a)-2.0 (b) -2 (c)2.0 (d)None of these
15 In SQL, which command is used to SELECT only one copy of each set 1
of duplicable rows
(a) SELECT DISTINCT (b) SELECT UNIQUE
(c) SELECT DIFFERENT (d) None of these
16 A database _______ is a special control structure that facilitates the row 1
by row processing of records in the result set.
(a) fetch (b) table (c) cursor (d) query
Q17and18areASSERTIONANDREASONINGbasedquestions.Markthecorrectchoicea
s
(a) BothAandRaretrueandRisthecorrectexplanationforA
(b) BothAandRaretrueandRisnotthecorrectexplanationforA
(c) AisTruebutRisFalse
(d) Aisfalse butRisTrue
17 Assertion (A): Parameters with default arguments can be followed by 1
parameters with no default argument.
Reasoning (R): Syntactically, it would be impossible for the interpreter
to decide which values match which arguments if mixed modes were
allowed while providing default arguments.
18 Assertion(A):CSV(Comma separated values) is a file format for data 1
storage which looks like a text file .
Reasoning(R):The information is organized with one record on each
line and each field is separated by comma .
SECTION – B
19 Rewrite the following code in python after removing all syntax error(s). 2
Underline each correction done in the code.
deffunc(a):
for i in (0,a)
if i%2 =0:
s=s+1
else if i%5= =0:
CS-SQP-2022 Page 3 of 12
m=m+2
else:
n=n+1
print(s,m,n)
func(15)
20 Write twoadvantagesandtwodisadvantagesofringtopology. 2
OR
Write two points of difference between HTML and DHTML .
21 (a) GivenisaPythonstringdeclaration: 1
str = "WELCOME TO STREET NO 234"
Writetheoutputof:print(str[3:-6])
(b) Writetheoutputofthecodegivenbelow:
my_dict = {'Name': 'Ronit', 'Perc': 92.5}
my_dict['Perc']+=5.0 1
my_dict['class']="X"
print(my_dict.values())
22 Differentiate between DDL and DML . 2
23 (a) Writethefullformsofthefollowing: 1
(i) NFS (ii)NIC
(b) Whatdo you understand by firewall ? 1
24 PredicttheoutputofthePythoncodegivenbelow: 2
deffunc(b):
global x
print('Global x=',x)
y=x+b
x=7
z=x-b
print('Local x=',x)
print('y=',y)
print('z=',z)
x=5
func(10)
OR
PredicttheoutputofthePythoncodegivenbelow:

tup = (10,28,35,45,39,88)
li =list(tup)
new_li = [ ]
for i in li:
if i%5==0:

CS-SQP-2022 Page 4 of 12
new_li.append(i)
nt = tuple(new_li)
print(nt)

25 Differentiate between SQL commands DROP TABLE and DROP VIEW. 2


OR
Writethecategoryof DMLorTCLforthefollowingcommands.
COMMIT, DELETE,ROLL BACK,UPDATE
SECTION - C
26 (a) Consider the following tables – Employee and Department : 1+2
Table : Employee
Ename Salary Dept
Mona 70000 10
Muktar 63000 20
Nalini 60000 30
Table : Department
Dept Dname
10 Computers
20 Economics
10 English
What will be the output of the following statement?
SELECT * FROM Employee NATURAL JOIN Department ;
(b) Write the output of the queries (i) to (iv) based on the table,
STOCK given below :
Table: STOCK
ITEMNO ITEMNAME DCODE QTY UNITPRICE
5005 Ball Pen 0.5 102 100 16
5003 Gel Pen 101 150 20
Premium
5002 Eraser Small 102 125 14
5006 Sharpener 103 200 22
Classic
5001 Eraser Big 101 60 5
(i) SELECT COUNT(DISTINCT DCODE) FROM STOCK;
(ii) SELECT ITEMNAME, DCODE FROM STOCK
WHEREUNITPRICE>=20 AND QTY>150;
(iii) SELECT * FROM STOCK
CS-SQP-2022 Page 5 of 12
WHERE ITEMNAME LIKE‟_ _ _ _ _ _ _ _ _ g‟;
(iv)SELECT DCODE,ITEMNAME FROM STOCK WHERE
UNITPRICE>=20 ORDER BY UNITPRICE DESC;
27 Write a method DISPLAY( ) in Python to read lines from a text file 3
STORY.TXT, and display those lines, which are starting with an
alphabet „A‟.
Example:
If the content of the file is
An apple a day keeps the doctor away.
We all pray for everyone‟s safety.
A marked difference will come in our country.

The DISPLAY() function should display the output as :


An apple a day keeps the doctor away.
A marked difference will come in our country.

OR
Write a method CHECK() in python to read lines from a text file
POEM.TXT, to find anddisplay the occurrence of the word “is”.

Example:
If the content of the file is

“India is the fastest growing economy. India is looking for more


investments around the globe. The whole world is looking at India as a
great market. Most of the Indians can foresee the heights that India is
capable of reaching.”

The CHECK() function should display the output as:


The number of is – 4
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
ACCOUNT and TRANSACT given below:

TABLE : ACCOUNT

ANO ANAME ADDRESS


101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simran Kaur Chandigarh
CS-SQP-2022 Page 6 of 12
TABLE : TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-05-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06

(i) SELECT ANAME ,TRNO,AMOUNT FROM ACCOUNT ,


TRANSACTWHERE ADDRESS NOT IN ('CHENNAI',
'BANGALORE')AND ACCOUNT.ANO= TRANSACT.ANO ;
(ii) SELECT DISTINCT ANO FROM TRANSACT;
(iii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM
TRANSACT GROUP BY ANO HAVING COUNT(*)> 1;
(iv) SELECT ANO , ADDRESS FROM ACCOUNT
WHERE ANAME LIKE „R%‟ ;
(b) A table, Voter has been created in a database with the following
fields VoterID, VNAME, Age &CITY .
Write the SQL command to change the column name VoterID to VID.
29 WriteafunctionCOMMON() to accept lists as argumentand return the 3
list with common elements from both the lists .
Example:
IfL1contains[1,2,3,4,5] and L2 contains [2,4,6,8,10]
ThenL3willhave[2 , 4]
30 Julie has created a dictionary containing names and marks as key value 3
pairs of 6 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 (marks) is greater than 75.
● Pop and display the content of the stack.
Example:
If the sample content of the dictionary is as follows:

CS-SQP-2022 Page 7 of 12
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
The output from the program should be: TOM ANU BOB OM
OR

WAF in Python PUSH(Arr) , where Arr is a list of numbers. from this list
push all numbers divisible by 10 into a stack implemented using a list .
Display the stack if it has at least one element otherwise display
appropriate error message .
SECTION - D
31 HerbalcityPharma is pharmaceutical company that has set up anew
unitin Himachal Pradesh .They have the following blocks onthe campus
: Thedistancebetweenvariousblocksisasfollows:
AccountstoResearchLab 55m
AccountstoStore 150m
StoretoPackagingUnit 160m
PackagingUnittoResearchLab 60m
Accounts to PackagingUnit 125m
StoretoResearchLab 180m
NumberofComputers
Accounts 35
ResearchLab 110
Store 25
PackagingUnit 70
Asanetworkexpert,providethebestpossiblesolutionsforthefollowing:

Accounts Research Lab

Store Packaging Unit

(i) Suggestacablelayoutofconnectionsbetweentheblocks. 1
(ii) Suggestthemostsuitableblocktohousetheserverofthisorganization. 1
(iii) Suggestthetypeofnetworktoconnectalltheblockswithsuitable
reason. 1
(iv) WhatwillbeneededtoprovidewirelessInternetaccesstoall 1
CS-SQP-2022 Page 8 of 12
smartphone/laptopusersindifferent blocks ?

(v) Suggest the devices to be installed in each of the buildings for 1


connecting computers installed within the building out of the
following :
a) Gateway (b) Modem (c) Switch
32 (a) Write the output of the code given below: 2+3
def change(P,Q=50):
P=P+Q
Q=P-Q
print(P,'#',Q)
return P
R=300
S=100
R=change(R,S)
print(R,'#',S)
S=change(S)
print(R,'@',S)
(b) The given program is used to connect with MySQL and show the
name of the all the record from the table “stmaster” from the database
“oraclenk”. You are required to complete the statements so that the
code can be executed properly.
import _____.connector__pymysql
dbcon=pymysql._____________(host=”localhost”, user=”root”,
_____________=”sia@1928”,database=“oraclenk”)
if dbcon.isconnected()==False :
print(“Error in establishing connection:”)
cur=dbcon.______________()
query=”select * from stmaster”
cur.execute(_________)
resultset=cur.fetchmany(3)
for row in resultset:
print(row)

CS-SQP-2022 Page 9 of 12
dbcon.______()

OR
(a) Predict The output of the code given below :
s='School34@Com'
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+'*'
print(m)

(b)
Aarvi is trying to connect Python with MySQL for her project. Help
her to write the python statement on the following:-
(i) Name the library, which should be imported to connect MySQL with
Python.
(ii)Name the function, used to run SQL query in Python.
(iii) Write Python statement of connect function having the arguments
values
as :Host name :192.168.11.111
User : root
Password: Admin
Database : MYPROJECT
33 Whatistheadvantageofusingacsvfileforpermanentstorage? 5

WriteaPrograminPythonthatdefinesandcallsthefollowinguserdefinedfunct
ions:
(i) ADD() – To acceptthe user id and password of some users to a
CSV file„user_info.csv‟. Each record consists of a list with field
elementsasuser id and passwordtostorethe details .

(ii) SEARCH()–Toread and search the password of the given user id


from theCSVfile„user_info.csv‟‟.

CS-SQP-2022 Page 10 of 12
OR
Give any one point of difference between a binary file and a csv file.

Write a Program in Python that defines and calls the following


userdefinedfunctions:
ADD() – To accept name and marks in 3 subject of 3 students into a
CSVfile„Student.csv‟. Calculate the total marks of each
students and store each record into a list with field
elementsasname, marks in 3 subjects and total marks.
Display()-Todisplaytherecordsofall the students .
SECTION - E
34 Table : Employee
1+1+2
Eno Ename Salary Zone Age Grade Dept
1 Mona 70000 East 40 A 10
2 Muktar 71000 West 45 B 20
3 Nalini 60000 East 40 A 10
4 Sanaj 65000 South 36 A 20
5 Surya 70000 North 30 B 30
Table : Department
Dept Dname Hod
10 Computers 1
20 Economics 2
30 English 3
Employee and Department are related in database .
Based on the data given above answer the following questions :
(i) Whichfieldshouldbemadetheprimarykey of Employee table ?
(ii) Which field will be considered as the foreign key if the table
Employee and Department are related in database ?
(iii) Write the statements to:
a. Insert the following record into table Department
Dept-40 , Dname- Physics Hod – 4
b. Update the salary of all Employees of East zone by 10% of
Employee table .
OR ( Option for part iii only)
(iii)Write the statements to:
a. Delete the record of all Employees whose Grade is „B‟ from
CS-SQP-2022 Page 11 of 12
Employee table.
b. Add a column UNIVERSITY in the table Department with
datatype as varchar with 25 characters .
35 Arun, during Practical Examination of Computer Science, has been
assigned an incomplete search() function to search in a pickled file
student.dat. The file student.dat is created by his Teacher and the
following information is known about the file.

•File contains details of students in [roll_no,name,marks] format.

• File contains details of 10 students (i.e. from roll_no 1 to 10)


and separate list of each student is written in the binary file
using dump().

Arun has been assigned the task to complete the code and print
details of roll number 1.

def search():
f = open("student.dat",________) #Statement-1
try:
while True:
rec = pickle.____ #Statement-2
if(____): #Statement-3
print(rec)
except:
pass
f.close()
1
(i) Name the module he should import in Line 1.
1
(ii) In which mode, Amit should open the file to read data from the
file in Statement 1 ? 2
(iii) Fill in the blank in Statement 2 to read the data from the binary
file „Student.dat‟ and in Statement 3 to get the details of roll
number 1 .

CS-SQP-2022 Page 12 of 12
SAMPLE QUESTION PAPER
CLASS: XII Session: 2022-23
Computer Science (083)
MARKING SCHEME - 10
Marks
QSTN Value Points Allotted
NO
SECTION – A
(1 mark to be awarded for every correct answer)

1 False 1

2 (c) string 1

3 (d) Error 1

d) DAV_CMC
4 1

5 b. [“Comput”,”Science”] 1

6 a. raw string 1

7 (a) GROUP BY 1

8 (b) LIKE operator 1

9 (d)Statement 4 1

10 (c) Alternate Key 1


(a) Any character such as the comma (,) or tab (\t) that is used to
11 separate the column data. 1

(c)SELECT * FROM Students


12 WHERE FirstNameLIKE „%a‟ ; 1

13 (b) Router 1
14 (b) -2 1
15 (a) SELECT DISTINCT 1
16 (c) cursor 1
17 (b) A is false but R is true. 1
18 (a) BothAandRaretrueandRisthecorrectexplanationforA 1

SECTION – B
19 deffunc(a): 2
s=m=n=0
for i in (0,a):
if i%2==0:
s=s+1
elif i%5==0:
m=m+2
else:
n=n+1
print(s,m,n)
func(15)
(½ mark for each correct correction made and underlined.)
20 Ring Topology 2
Advantages Disadvantages

Thisarrangementprevent Needsmorecablethanbus.
scollisions.
Datapacketstravelatgreat Anysnaginthecableringcr
erspeeds ashesthenetwork
Anyproblemswithdev Thenetworkactivityisdist
iceandcablecanbeeas urbedwhenaddingorremo
ilylocated. vinganode

(1markforeachcorrectpointofdifference – any two)


OR
HTML
HTML is a markup language.
HTML is used to create static webpages.
DHTML
DHTML is a collection of technologies.
DHTML is capable of creating dynamic webpages.
(1markforeachcorrectpointofdifference)
21 (a) COME TO STREET 1
(1 mark for the correct answer)
(b) dict_values(['Ronit', 97.5, 'X']) 1
(1 mark for the correct answer)
22 The Data Definition language (DDL) commands , as the name suggest , 2
allow you to perform tasks related to data definition. That is, through
these commands , you can perform tasks like , create ,alter and drop
schema object .
The Data Manipulation language(DML) commands, as the name
suggests, are used to manipulate data. That is, through these commands ,
you can perform tasks like , insert into , update & delete .

(1 mark each for correct explanation )


23 (a) NFS – Network file system. 1
NIC – Network interface card
(½ mark for every correct full form)
(b) The system designed to prevent unauthorized access to or from a
private network is called firewall.
(1markforcorrectanswer) 1
24 Global x= 5 2
Local x= 7
y= 15
z= -3
(½ mark for the correct line of output)
OR
(10, 35, 45)
( ½ mark for each correct digit and ½ mark for enclosing in parenthesis)
25 DROP TABLE command removes a table from database and all its 2
dependant objects such as views and DROP VIEW command removes a
view from the database without affecting its base table .
(1 mark each for correct explanation )
OR
DML: u p d a t e , delete
TCL: r o l l b a c k ( ) , c o m mi t ( )
(½ mark for each correct categorization)
SECTION - C
26 a. 1+2
Dept Ename Salary Dname
10 Mona 70000 Computers
10 Mona 70000 English
20 Muktar 63000 Economics
( 1 mark for correct output)

(b)(i) DISTINCT DCODE


------------------------
3
( ½ mark for the correct output)
(ii) ITEMNAME DCODE
---------------- ----------
Sharpener Classic 103
( ½ mark for the correct output)

(iii)
ITEMNO ITEMNAME DCODE QTY UNITPRICE
5001 Eraser Big 101 60 5
( ½ mark for the correct output)
(iv)
DCODE ITEMNAME
103 Sharpener Classic

101 Gel Pen Premium

( ½ mark for the correct output)


27 def DISPLAY(): 3
file=open('STORY.TXT','r')
line=file.readline()
while line:
if line[0]=='A' :
print( line)
line=file.readline()
file.close()
½ mark for correctly opening and closing the file
½ for readline()
½ mark for correct loop
½ for correct if statement
½ mark for correctly display the lines
½ mark for reading the lines until the last line
OR
def CHECK():
c=0
file=open('POEM.TXT','r')
lines = file.read()
while lines:
words = lines.split()
for w in words:
if w=="is":
c=c+1
lines = file.read()
print (“ The number of is- ”, c)
file.close()
½markforcorrectlyopening and closingthefile
½ mark forread()
½markforcorrectloop
½forcorrectifstatement
½markforcorrectly incrementing counter c
½markfor displaying c
Note: Any other relevant and correct code may be marked
28 a. (i) 3
ANAME TRNO AMOUNT
Ali Reza T002 3000

( ½ mark for the correct output)


(ii) DISTINCT ANO
--------------------
101
102
103
( ½ mark for the correct output)
(iii) ANO COUNT(*) MIN(AMOUNT)
------- ------------- ---------------------
101 2 2500
103 2 1000
( ½ mark for the correct output)
(iv) ANO ADDRESS
------ --------------
102 CHENNAI
104 CHENNAI
( ½ mark for the correct output)

(b) ALTERTABLEVoter
change VoterId Vid int ;
(1 mark for correct statement )
29 defCOMMON(L1,L2): 3
L3=[]
for i in L1:
if i in L2:
L3.append(i)
return L3
(½ mark for correct function header
1mark for correctloop
½ mark forcorrectifstatement
½ mark for append
½markforreturnstatement)

Note:Anyotherrelevantandcorrectcodemaybemarked
30 R={"OM":76, "JAI":45, "BOB":89,"ALI":65, "ANU":90, "TOM":82} 3
def PUSH(S,N):
S.append(N)
def POP(S):
if S!=[]:
return S.pop()
else:
return None

#_main_
ST=[]
for k in R:
if R[k]>=75:
PUSH(ST,k)
while True:
if ST!=[]:
print(POP(ST),end=" ")
else:
break
1 mark for loop defined within main()
½ mark for correct push() definition
1 markfor correct pop()
½mark forcorrectdisplay
OR
defPUSH(Arr):
stk=[ ]
top=None
for i in Arr:
if i%10==0:
stk.append(i)
top=len(stk)-1
if top==None:
print("No elements in the given list is divisible by 5")
else:
print("Stack formed is:")
print(stk[top],"<-Top")
for i in range(top-1,-1,-1):
print(stk[i])
Arr=eval(input("Enter a list of numbers:"))
PUSH(Arr)

1 ½ mark for correct PUSH()


1 ½ mark forcorrectdisplay
SECTION - D

31 (i) 1

Research
Accounts
Lab

Store Packaging

unit

(ii) Research Lab since it has the maximum number of computers. 1


( ½ mark for naming the server block and ½ mark for correct
reason.)

(iii) Sincethedistancebetweentheblocksislessthan1KmandLANcanb 1
eup to10Km .
( ½ mark for type of networkLAN and ½ mark for correct
reason.)

(iv) A HighbandwidthBroadbandConnectionandWi-FiRouter.
1
(1 mark for the correct answer)

(v) Switch
1
(1 mark for the correct answer)
32 (a) 2+3
400 # 300
400 # 100
150 # 100
400 @ 150
(½ mark for each line of corrected output statement)
(b)
import mysql.connectoraspymysql
dbcon=pymysql.connect(host=”localhost”, user=”root”,
password=”sia@1928”)
if dbcon.isconnected()==False:
print(“Error in establishing connection:”)
cur=dbcon.cursor()
query=”select * from stmaster”
cur.execute(query)
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon.close()
( ½ mark for each corrected statement)
OR
(a) sCHOOL***cOM
(1 mark for first 6 characters & 1 mark for next 6 characters)
(i) import mysql.connector
(ii) execute (<sql query >)
(iii)mysql.connector.connect(host=”192.168.11.111”,
user=”root”,password=”Admin”,database=”MYPROJECT”)
( 1 mark for each correct statement)
33 Advantageofacsvfile:
 Itishumanreadable– 5
canbeopenedinExcelandNotepadapplications
 Itisjustliketextfile
1markforadvantage
import csv
def ADD():
with open("user_info.csv", "w") as obj:
fileobj = csv.writer(obj)
fileobj.writerow(["User Id", "password"])
while(True):
user_id = input("enter id: ")
password = input("enter password: ")
record = [user_id, password]
fileobj.writerow(record)
x = input("press Y/y to continue and N/n to terminate the
program\n")
if x in "Nn":
break
elif x in "Yy":
continue
def SEARCH():
with open("user_info.csv", "r") as obj2:
fileobj2 = csv.reader(obj2)
given = input("enter the user id to be searched\n")
for i in fileobj2:
next(fileobj2)
if i[0] == given:
print(i[1])
break

½markforimportingcsvmodule
1 ½marks each for correct definition of ADD() andSEARCH()
½markforfunctioncallstatements
OR
Differencebetweenbinaryfileandcsvfile:(Anyonedifferencemaybegive
n)
Binaryfile:
 Extensionis.dat
 Nothumanreadable
 Storesdataintheformof0sand1s
CSVfile
 Extensionis.csv
 Humanreadable
 Storesdatalikeatextfile
1markfordifference

import csv
def ADD():
f=open('Student.csv','w')
res=csv.writer(f)
res.writerow(['Name','Sub1','Sub2','Sub3','TotalMarks'])
b=[]
for i in range(3):
name=input('Enter the name')
m1=int(input('Enter the mark of subject1'))
m2=int(input('Enter the mark of subject1'))
m3=int(input('Enter the mark of subject1'))
Total=m1+m2+m3
L=[name,m1,m2,m3,Total]
b.append(L)
res.writerows(b)
f.close()
def Display():
f=open('Student.csv','r')
rec=csv.reader(f)
for i in rec:
if i==[]:
continue
else:
print(i)
ADD()
Display()
½markforimportingcsvmodule
1½markseachforcorrectdefinitionofADD() & Display()
½markforfunctioncallstatements
SECTION - E
34 (i) Eno 1+1+2
(1 mark for correct answer)
(ii) Dept
(1 mark for correct answer)
(iii) a. insert into Department values(40,‟Physics‟,4) ;
b.update Employee set Salary = Salary + Salary*0.10
where Zone=‟East‟ ;
(1 mark for each correct statement)
OR
(iii) a. delete from Employee where Grade=‟B‟ ;
b. alter table Department add(University varchar(25)) ;
(1 mark for each correct statement)
35 (a) pickle 1
(1 mark for correct module)
(b)rb 1
(1 mark for correct file mode)
(c) load(f) (Statement 2 ) , rec[0]==1 (Statement 3) 2
(1 mark for each correct statement)

You might also like