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

SAMPLE QUESTION PAPER - 1

CLASS- XII
SUB: COMPUTER SCIENCE(083)

Time Allowed: 3 Hours Maximum Marks: 70


General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. SectionAhave18questionscarrying01markeach.
4. SectionBhas07VeryShortAnswertypequestionscarrying02markseach.
5. SectionChas05ShortAnswertypequestionscarrying03markseach.
6. SectionDhas03LongAnswertypequestionscarrying05markseach.
7. SectionEhas02questionscarrying04markseach.Oneinternalchoiceisgiven
in Q35against part C only.
8. All programming questions are to be answer during Python Language only.

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

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

Which statement will merge the contents of both dictionaries?


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

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

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


for slicing operation?

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

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

7. Fillintheblank: 1

Commandisusedtorename a columnfromthetableinSQL.

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

8. Whichofthefollowingcommandswillchange the row values in theMYSQL table? 1


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

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


followingcode?

P="I LOVE PYTHON" # Statement


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

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

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

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


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

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

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

13. Fillintheblank: 1
Isacommunicationmethodologydesignedtodeliverbothvoice
andmultimediacommunicationsoverInternetprotocol.

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

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

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

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

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

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

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

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


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

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

SECTIONB

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

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

20. WritetwopointsofdifferencebetweenBus topology and Star topology. 2

OR

WritetwopointsofdifferencebetweenCDMAandWLL.

21. (a) GivenisaPythonstringdeclaration: 1


CBSE="##ANNUAL Examination2023##"

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

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

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

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

24. PredicttheoutputofthePythoncodegivenbelow: 2

def CALC (P1,P2):

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

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

OR

PredicttheoutputofthePythoncodegivenbelow:

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


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

OR

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

SECTIONC

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


Table:Customer_Details

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

5
Table:Department
AC Location

A01 Delhi
A02 Mumbai
A01 Nagpur

Whatwillbetheoutputofthefollowingstatement?

SELECT*FROMCustomer_DetailsNATURALJOINDepartment;

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

Table:MY_SUBJECT

ID NAME AMOUNT DURATION PID


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

(i) SELECTDISTINCTPIDFROMMY_SUBJECT;

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

MY_SUBJECT GROUPBYPIDHAVINGCOUNT(PID)>1;

(iii) SELECT NAME FROM MY_SUBJECTWHERE

AMOUNT >15000ORDERBYNAME;

(iv) SELECTAVG(AMOUNT)FROMMY_SUBJECT WHERE

AMOUNT BETWEEN15000AND17000;

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

Example:

Ifthefilecontentisasfollows:

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

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

OR

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


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

Example:

Ifthefilecontentisasfollows:

Todayisapleasantday.It is likely torain today.


It is mentionedonweathersites.

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

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

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

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

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

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


Department=J.Department;
(iv)Writethecommandtoviewalltablesinadatabase.

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

Forexample:

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

TheODD_LISTwillhave[3,4,6]

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

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

The output should be:


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

OR

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


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

Forexample:Ifthedictionarycontainsthefollowingdata:

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

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

App Kashipur
Development Campus Movie
Mussoorie Editing
Campus
Web
Designing

Distancebetween variousblocks/locations:

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

Numberofcomputers
Block Number of
ComputersAppdevelopment 75
Webdesigning 50
Movieediting 80

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


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

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

32. (a) Writetheoutputofthecode givenbelow: 2+3

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

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

(b) ThecodegivenbelowinsertsthefollowingrecordinthetableStudent:

RollNo –
integerName –
stringClass –
integerMarks–
integer

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

importmysql.connectorasmysql

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

print("DataAddedsuccessfully")

OR

(a) Predicttheoutputofthecodegivenbelow:

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

(b) Thecodegivenbelowreadsthefollowingrecordfromthetablenamed student


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

Note the following to establish connectivity between Python andMYSQL:


 Usernameisroot
 Passwordistiger
 ThetableexistsinaMYSQLdatabasenamedschool.

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

importmysql.connectorasmysql
defsql_data():

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

a)Whatistheadvantageofusingacsvfileover text file ?


b)WriteaPrograminPythonthatdefinesandcallsthefollowinguser defined
functions:

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


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

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

Write a Program in Python that defines and calls the following


userdefinedfunctions:

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


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

(ii) SearchRecord()-Todisplaytherecordsofthefurniturewhose
Priceismorethan 3500.

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

SID SNAME SEM1 SEM2 SEM3 DIVISION

101 KARAN 366 410 402 I


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

107 NEELAM 470 450 471 I

Basedonthedatagivenaboveanswerthefollowingquestions:

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


asPrimary key.

Iftwocolumnsareaddedand2rowsare deletedfromthetableresult,
Whatwill bethenew degreeandcardinalityoftheabovetable?

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

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

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

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

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


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

14

You might also like