Sample Question Paper - 1 Class-Xii Sub: Computer Science
Sample Question Paper - 1 Class-Xii Sub: Computer Science
Sample Question Paper - 1 Class-Xii Sub: Computer Science
CLASS- XII
SUB: COMPUTER SCIENCE(083)
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