Study Material XII Computer Science
Study Material XII Computer Science
FOR
ANNUAL EXAMINATION: 2022-23
CLASS-XII
SUBJECT- COMPUTER SCIENCE
FEATURES
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}
(a) True
(b) False
(c) NONE
(d) NULL
a) print(list1[2:])
b) print(list1[:2])
c) print(list1[:-2])
d) all of the mentioned
1
6. Whichofthefollowingmodeinfileopeningstatementresultsor 1
Generatesanerrorifthefiledoesnotexist?
7. Fillintheblank: 1
Commandisusedtorename a columnfromthetableinSQL.
(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
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.
14. WhatwillthefollowingexpressionbeevaluatedinPython? 1
print(16.0 // 2 + (7 * 4.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.
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
OR
WritetwopointsofdifferencebetweenCDMAandWLL.
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
24. PredicttheoutputofthePythoncodegivenbelow: 2
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:
OR
CategorizethefollowingcommandsasDDLorDML:
CREATE VIEW,GROUP BY, DROP, ALTER,SELECT
SECTIONC
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
(i) SELECTDISTINCTPIDFROMMY_SUBJECT;
MY_SUBJECT GROUPBYPIDHAVINGCOUNT(PID)>1;
AMOUNT >15000ORDERBYNAME;
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
Example:
Ifthefilecontentisasfollows:
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;
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]
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.
OR
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
9
(iv) Suggesttheplacementofthefollowingdeviceswithappropriatereasons:
a. Switch/Hub
1
b. Repeater
(v) Suggest a protocol that shall be needed to provide
VideoConferencingsolutionbetweenKashipurCampusandMussoorieCa
mpus. 1
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)
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()
Give any one point of difference between a binary file and a csv file.
(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.
Basedonthedatagivenaboveanswerthefollowingquestions:
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()
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()
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)
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)
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
CLASS-XII
General Instructions:
(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.
[“Lenovo”, 75000]
[ “HP”,72000]
[”Apple”, 110000]
[“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
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
(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:
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
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.
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.
(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
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
import csv
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
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 display the entire content of the CSV file by calling the function readcontents().
(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)
(iv) DateOfOrder
03-Jan-2018
(1.5 marks for correct push_element() and 1.5 marks for correct
pop_element())
OR
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
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()
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()
iii) Additem(101,‟Sofa‟)
readcontents()
(1 mark for each correct statement)
SAMPLE QUESTION PAPER - 3 (2022-23)
CLASS- XII
SUB: COMPUTER SCIENCE (083)
General Instructions:
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
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
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
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
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.
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
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 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
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)
(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
#2
connect(host="localhost",user="TECHIT",password="tech
", database="Employee")
#3 con1.commit()
#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;
CLASS- XII
SUB: COMPUTER SCIENCE(083)
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}
(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
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())
(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;
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
27.WriteamethodCOUNTLINES()inPythontoreadlinesfromtextfile
„TESTFILE.TXT‟ and display the lines which are not ending with any
digit. 3
OR
Ifthefilecontentisasfollows:
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.
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]
Ifthelistsofbookdetailsare:
[“C++”,“Comp Sc”,200]
[“Light”,“Physics”,350]
[“Plants”,”Biology”,200]
[“Python”,“Comp Sc”,300]
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
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()
STD-XII/COMP.SC PAGE- 13
(ii) search()-Todisplaytherecordsof all books.
SECTION-E
Table:RESULT
Basedonthedatagivenaboveanswerthefollowingquestions:
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()
(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 advantage and ½ mark for each correct disadvantage.)
21 a. Ans: git 2
(1mark for the correct answer)
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)
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
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)
(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)
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
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(*)
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.
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
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
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.
HR BLOCK ACCOUNTS
HEAD OFFICE
BLOCK
LOGISTIC
BLOCK
(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
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
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.
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.
*****
1 c) _tax 1
2 (b)None 1
(a) dict_exam.update(dict_result)
3 1
4 (b)False 1
6 (a) w+ 1
7 d) DROP 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
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.
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
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)
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()
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( )
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?
8 Which of the following command will delete the field from the table from 1
MYSQL database?
(a) Statement 3
(b) Statement 4
(c) Statement 5
(d) Statement 4 and 5
10 Fill in the blank: 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.
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
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 |
+---------------------+--------------------------+--------------------------+
(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
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”]
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
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
OR
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
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()
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.
(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
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.
Ans:(C) alter
(1 mark correct answer)
8 Which of the following command will delete the field from the table from 1
MYSQL database?
Ans: (d)
(1 mark correct answer)
9 Which of the following statement(s) would give an error after executing 1
the following code?
(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
(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.
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
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
Ans:
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.
Ans:@2 ina B@
Ans: dict_keys([('name','age',‟address‟)])
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
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)
OR
Ans:
DDL- ALTER, DROP
DML – INSERT, UPDATE
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:
(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
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
COUNTLINES()
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:
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
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}
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)
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
a. Suggest and draw the cable layout to efficiently connect various blocks
of buildings within the Noida center for connecting the digital devices
WAN
(1 mark for the correct answer)
Satellite
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.)
Ans:
25#7#
(b) The code given below inserts the following record in the table Student:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Ans:
con1.cursor()# Statement 1:
mycursor.execute(querry) #Statement 2:
con1.commit() #Statement 3:
(1 mark for each correct answer)
OR
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
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.
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)
Ans:
a. DELETE FROM RESULT WHERE DIV=‟IV‟;
b. ALTER TABLE RESULT ADD (REMARKS VARCHAR(10));
Ans: pickle
(1 mark for correct module)
(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?
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
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
OR
Administrative Block
(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)
SECTION E
34. Observe the following table and answer the parts (a) to (c): 1+1+
2
(b) float
2 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)
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
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)
#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)
OR
stack=[]
def push(stack,item):
stack.append(item)
def POP(stack):
if stack==[]:
print("Underflow error")
return None
else:
return stack.pop()
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()
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))
15 Which of the following aggregate function does not ignore nulls in its results? 1
(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
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.
(b) Which protocol helps us to transfer files to and from a remote computer?
“OR”
“OR”
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)
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
TRAINER and COURSE given below:
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:
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.
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.
“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()
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:
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)
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()
*******
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.)
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
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
“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.)
(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(' ')
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' )
frequency = { }
list = ['a','b','c','a','c']
for index in list:
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:
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)
(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( )
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
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)
***
SAMPLE QUESTION PAPER - 10
CLASS: XII
Session : 2022-23
COMPUTER SCIENCE(083)
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
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)
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
TABLE : ACCOUNT
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:
(i) Suggestacablelayoutofconnectionsbetweentheblocks. 1
(ii) Suggestthemostsuitableblocktohousetheserverofthisorganization. 1
(iii) Suggestthetypeofnetworktoconnectalltheblockswithsuitable
reason. 1
(iv) WhatwillbeneededtoprovidewirelessInternetaccesstoall 1
CS-SQP-2022 Page 8 of 12
smartphone/laptopusersindifferent blocks ?
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 .
CS-SQP-2022 Page 10 of 12
OR
Give any one point of difference between a binary file and a csv file.
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
9 (d)Statement 4 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
(iii)
ITEMNO ITEMNAME DCODE QTY UNITPRICE
5001 Eraser Big 101 60 5
( ½ mark for the correct output)
(iv)
DCODE ITEMNAME
103 Sharpener Classic
(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)
31 (i) 1
Research
Accounts
Lab
Store Packaging
unit
(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)