0% found this document useful (0 votes)
28 views6 pages

CS Sample Paper I (Solved)

The document outlines instructions for a computer science examination, including SQL and Python programming tasks. It includes questions on data handling, error management, and function definitions, along with specific examples and expected outputs. Additionally, it provides a scenario for creating and manipulating a database table and performing operations on a stack data structure.

Uploaded by

vishnuvk1705
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views6 pages

CS Sample Paper I (Solved)

The document outlines instructions for a computer science examination, including SQL and Python programming tasks. It includes questions on data handling, error management, and function definitions, along with specific examples and expected outputs. Additionally, it provides a scenario for creating and manipulating a database table and performing operations on a stack data structure.

Uploaded by

vishnuvk1705
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

6. 5. 4.

2 GENERAL Maximum
Marks:70
3. 1. viiL vü. INSTRUCTIONS: i . i.
and
FTP(C) PPP(A) Which cardinality
avg(C)()sum(A)() In(D)) (C) (B) (A) random.
print R=foSignal
r random code What
importexpected
SQL, (16*5/4*25-8)
0.(C0) (A33
)-3print UNIQUE (
WhatDISTINCT C) (A) The
written
parameters While State Section
receive RED K repetition. AlSection Section
Section Section ThePlease
YELLOWGREEN YELLOW (Signal in is
protocol the =('RED', executedpossible
range will SELECT True programming Paper
aggregate # afterdefining
emails of e GREEN to E, D, C, B, A, check
the # randrange
(R], (K) be be or consists Consists
consists
Consists consists is
#RED # (2, the the in False: divided this
out table GREEN ?
over RED end YELLOW 0, displayedoutput returns
dause, the
of # # -1): output statement
default a question
function fu =#)
# functionSECTION-questions
funcion A of ofof5 of of
(D) HTTT(B)
SMTPcomputer athe su()
(mD)count(B(*)) is 3 2 7 18into
following # from -13.33
(D ) 6.
(B0) questions
questionsquestions
questions CBSE
when of
DESCRIBE
NULL(D) (B) parameters. questions paper 5
', the Sections
which GREEN when header in
are
the the following Python, to contain
network
is wil followinggiven be(33 (31 (26 (19 (1 COMPUTER
SCIENCE
used ] without
records answered to to to to toA,B, -
combined must
display 35). 32). 30). 25). 18). 35 Board
to options statement: the C,D
send always Each Each Each Each Eachquestions.
Python positional using and
t1he
with
question question
question question
question
Solved
Paper
Class-
1 is E.
13. be Language
Python
only Py Examination
12. 11.
While False:State (C)30
correct
(Select convert
A)10theprint
(a) (10) convert(a): a=20 10. carriescarries
carriescarriescarries
defObserve (C)Hz(AKB
measurement
Presidency@2023'
) Which (D) 8. 7.
a=a+b b=20 (Presidency@2023] (G20](C) (B) G20(AL=event.
(print
) (L[: raisean
handling whether Identify
-2]): event=Selectprint(C) (AMISS#IPPIS
) error:
MISSI#SIPPI
he (C) (A)print
t"MISSISSIPPI"
myStr=choose
Consider following.
()
f= (d=
A) Identify 5 4 3 2 1 12th
of marks. marks.
the marks. marks.mark.
the
t"he print (myStr
given split correct
G20 ("15" 3)
the
exceptions the followingfor +"A" (
output
fromthe statement the dict() the
following Presidency ( [:correct
Python network )output *3) 4]
statements invalid
Error(D) (B)20 +"
(DKm output
in ) (BBi) toptions #"+ -
Python,statement
code bandwidth @2023" of(D) print (5*3)
MISSI#IPPIS
from (D)
(B) MISS#SIPPI (B)
theprint {}
) Python
(D)'g=(Be= 2024
options:
given carefully: the myStr from givendict{}
is following
the the statement
name ("15" following (-5:)
is ?
correct givenbelow Time
+
of True code: "13") allowed:
the unit which options: and
1 or from
1 1 of wil then 3
1 the hours
1 1

20. (B) 19.(A) 18. 17.


EvenOdd) Underline
EvenOdd
for def() Observe 16.
after displays The (iü) (i) (ii) (i) Reason
for Python where
AssertionsingleReasoncommaAssertion (D) (C) (B) (Aquestions. 15.
Odd")
print ("else: if i ) Markbased(R) Q.(C) Python (A) Which
? Consider
codeNameDefine packet e Expand
and GivXML, strings (A ) 17 network.
successful by UPDATE Fil (C)DROP(A) SQL which soPaperlved2s024
num/ numrange inrenoving PPP row each correct
(explanation
A) Both (Afo)r.Both
the E F the in
?clause.
= whether
the (R): wil (R): or is is and seek seek (CONTENT.F=open TXT) exception
2int all given any the one insort (A): in some (A): false true correct
(A ) of t he
("Even")
print (input= (5): following the the 18(0, the
the communicating and of
0: all two terim difference Python. give Thewriterowa line CSVexplanation (^) and are -1(1,0) blaisnk:a the
following () an CSV other has but but and ) following has
correctionssyntax theybelow switching. SECTION- B does choice
R)
(ASSERTION
following reliable set
following
web web
OR
error. file.
expression afile (R) (R) (R) of
to,
("Enter code are not delimiter.
()number is is is are as be
accepts
browsers. false. for are rules
and even hosting. between
terms: exist a (D) (B) compulsorily
carefully
method human true.
(^). true true isPython dataparties CREATE
ALTER
(D) (B)
a made.logical
of F. F an that is
number") or as
"HELLO" and (A) seek seek not
odd: five a isfields, and and
communication needs
invalidstatement:
circuit method/function (R) (0, (0, in a
errors: andnumbers used readable
(R) is 2) 1) order DDL added
separated REASONING to
rewrite switching 1+1=2 . to is the statement be
sort) text not corect to command
and write followed with
file over have
it 2 in by the except
a in
a a 1 1 in
23. 22. (B)
(B) for foD=(}
r "TEL_VIS_ON". 21.
tasks Write LS=["HIMALAYA",
K
following
Python
"TELEVISION" For string
code:Writereturn string andreplaced EnglishPuzzleWriteDAVID-ANAGMA -C -BThe For
deletedifferentto after (i) S AMIT"DAVID":
S=("AMIT": <60 >=60
<90but >=90
A isFor {"ANITA":
his
(ii) {"ANITA": For the in in example:N Average (A)
convert tuple example substring To from using
To D: if LS: the output exanple:
example, print len(S) is where (W, a following
grading
obtained [Eng an Write
rules:functionshowGrades
the book", display removal renove Python "TE_EV_SI 3, with word user
output N) of
argument.
lastsubjects.
the named 90, dictionary
90,
abuilt-in(K,D[K]
len(S)
DÊS] = % then if every should (92,Consider Math, a
if Wan andwhich defined 90, (92, Eng,Math, user
elementgiven "the
then the if is" "ASHA": if statement
th e 4 by
displays
"NISHA".76, the the ==
"NILGIRI,displayed _N". underscore
Ncontains
the N
he number
subject ORtstring in functionsmethods sep , is Nh be: 88]) 86, thScience]
e (S)
The defined
Write a as
takes OR
tuple dictionarynamed item 0: 4,
function 641, the which
of output string dictionary 92} = an
alphabet function
whose for "#) then
Likewise following Science students dictionary,
the
the toa the
stores message of
the integer
(""). the "NAGMA": as function
each "ALASKA", on the word takes
list. Python l named
wioccurrences "ASHA": Students. corresponding key:
list Students should argument
of in
should key of
be
execution function for
and the contains only: the "TELEVISION" the and Python dictionary
according value Sthe in
3.
message. is contains
dictionaryPython
commandsnames
thereafter 92}, treturn
he returns
word [65,
contains"NISHA"following "ALPS") W Grade
pairs.
contain
of 1+1=2 ofshould named 42, B A
"This then W as to Name: named
of the the
word the
the 43), grade
2 is an the The S
as 17
18 | OSWAAL CBSE | 19
Sample Question Papers, SolvedPapers2024
27
COMPUTER SCIENCE, Clas -12 defined functions in Python cSv file named Peripheral.csv, to store the details.4
24. (A) Ms. Veda created a table named Sports in a
MySQL database, containing columns Game
Consider
the
the table
ORDERS given Write the following
user
operations on a stack The structure of Peripheral . csv is:
2
output of the SQL queries that below and write d perform the speahed
id P_Age and G_name. follow: namedBigNums. P_id, P_name, Price]
After creating the table, she realized that the ORDNO ITEM 1x3=3
OTY RATE ORDATE PushBig(): It checks every number from the list where
attribute, Category has to be added. Help her to 1001 RICE 23 120 ) Nums and pushes all such numbers which have 5 or P id is Peripheral device ID (integer)
BigNums.
write a command to add the Category column.
Thereafter. write the command to insert the
1002 PULSES 13 120 2023-09-10 more digits into the slack,
It pops the numbers from the stack,
P_name is Peripheral device name (String)

following record in the table:


1003 RICE 2 110 2023-10-18 PopBig :
BigNums and displays them. The function
should Price is Peripheral device price (integer)
defined
2023-11-17 are no more Sangeeta wants to write the following user
Game id: G42 1004 WHEAT 26 65 also display "Stack Empty" when there
P_Age: Above 18 1005 PULSES 16 110
2023-12-25 numbers left in the stack.
functions:
Add Device (): to accept a record from
the user and
G_name: Chess 1006 WHEAT 27 55
2024-01-15 For example: If the list Nums contains the
following
add it to acsv file, Peripheral. cs.
Category: Senior
1007
2024-04-15 data:
1297653, 31498, Count_Device (): To count and display number of
1000.
OR WHEAT 25 60
2024-04-30 Nums = [213, 10025, 167, 254923, 14, peripheral devices whose price is less than
(B) Wite the SOL commands to perform the (i) SELECT ITEM, SUM (QTY) FROM ORDERS GROUP 386, 92765]
Big Nums
folowing tasks: BY ITEM; Then on execution of PushBig (), the stack SECTION- E
(i) View the list of tables in the database, Exam. (ii) SELECT ITEM, QTY FROM ORDERS WHERE should store:
management company
(ii) View the structure of the table, Terml. ORDATE BETWEEN [10025, 254923, 1297653, 31498, 92765] 33. Infotainment Ltd,. is an event The
25. Predict the output of the following code: output office located in Bengaluru.
2 "2023-11-01' AND "2023-12-31: And on execution of PopBig ( ), the following with its prime
its new division at
def callon (b=20, a=10): (iii) SELECT ORDNO, ORDATE FROM ORDERS should be displayed: company is planning to open Vajra,
b=b+a
WHERE ITEM = ' WHEAT AND RATE> =60;. 92765
three different locations in Chennai named as - 1x5=5
a=b-a Trishula and Sudershana.
31498 suggest solutions
print (b, "#) 28. (A) Wite a user defined function in Python named You, as a networking expert need to
1297653 keeping in miFd the
return b showlnLines () which reads contents of atext to the questions m part (i) to (v),
x=100 ile named STORY. TXT and displays 3 every 254923 distances and other given parameters.
y=200 sentence in a separate line. 3
10025
x=callon (x, y) Assume that a sentence ends with a full stop (), Stack Empty Bengaluru
office
print (x, "@"y) a question mark (?), or an exclamation mark ().
y=callon (y) SECTION- D Chennai Division
For example, if the content of fle STORY. TXT is
print (x, "@"y) as follows:
Our parents told us that we must eat vegetables 31. Consider the tables Admin and Transport given
SECTION- C 1X4 = 4 Vajra Trishula
to be healthy. And it turns out, our parents were below:
26. Write the output on execution of the following Table: Admin
right! So, what else did our parents tell?
Python code: Then the function should display the file's S id S name Address S_type |Sudershana
S="Racecar Car Radar" content as follows:
S001 Sandhya Rohini Day Boarder
L=S. split (0 Our parents told us that we must eat vegetables
for W in L: SO02 Vedanshi Rohtak Day Scholar Distances between various locations:
to be healthy.
x=W.upper ( ) SO03 Vibhu Raj Nagar NULL 350 m
if x= =x [::-1]: And it turns out, our parents were right! Vajra to Trishula
for Iin X: So, what else did our parents tell? S004 Atharva Rampur Day Boarder Trishula to Sudershana 415 m
print (I, end="*") OR Table: Transport
Sudershana to Vajra 300m
else: (B) Write a function, c_words () in Python that
for I in W. S id Bus no Stop_name BengaluruOffice to Chennai 2000 km
separately counts and displays the number of
print (l, end="#") uppercase and lowercase alphabets in a text file, S002 TSS10 Sarai Kale Khan Number of computers installed at various locations:
print () Words. bt. S004 TSS12 Sainik Vihar 120
Vajra
29. Consider the table Projects given below: 1x3=3 TSS10 Kamla Nagar 75
SO05 Sudershana
Table: Projects Write SQL queries for the following: Trishula 65
P id Pname Startdate (i) Display the student name and their stop name from Bengaluru Office 250
Language Enddate
PO01 School Management System Python 2023-01-12 2023-04-03 the tables
(i) Suggest and draw the cable layout to efficiently
PO02 Hotel Marnagement System C++ 2022-12-01 Admin and Transport. connect various locations in Chennai division for
2023-02-02 (ii) Display the number of students whose S type is not connecting the digital devices.
POO3 Blood Bank Python 2023-02-11 2023-03-02
PO04 Payroll Management System known. (ii) Which block in Chennai division should host the
Python 2023-03-12 2023-06-02 (iii) Display all details of the students whose name starts server? Justify your answer.
Based on the given table, write SQL queries for the following:
with 'V" (ii) Which fast and effective wired transmission medium
() Add the constraint, primary key to column P_id in (iii) To
the existing table Projects. delete the table Projects from MySQL database (iv) Display student id and address in alphabetical order should be used to connect the prime office at
along with its data. of student name, from the table Admin. Bengaluru with the Chennai division ?
(ii) To change the language to Python of the 30.
whose id is PO02. project Consider a list named Nums which contains random (iv) Which network device will be used to connect the
integers. 32. Sangeeta is a Python progranmner working
maintain
3 computer hardware company. She has to digital devices within each location of Chennai
the records of the peripheral devices. She created a
20 0SWAAL CBSE Sample Question Papers, COMPUTER
division so that they may communicate with each
other ?
(ii)) Sunil wants to write a SCIENCE,
program in Python toClupdate
ass-12
the quantity to 20 of the
(v) Aconsiderable amount of data loss is noticed between is 111 in the table records
named shop in whOse item code
different locations of the Chennai division, which named Keeper. MySQL database
are connected in the network. Suggest a networking The table shop in MySQL
contains the
device that should be installed to refresh the data and
reduce the data loss during transmission to and from
attributes:
" Item code: Item code (Integer)
fol owing
different locations of Chennai division.
" Item name: Name of item (String)
34. (A)(i) Differentiate between 'w' and 'a' file modes in
Python. 2+3=5
" Qty: Quantity of item (Integer)
(iü) Consider a binary file, items . dat, containing records " Price: Price of item (nteger)
stored in the given format: Consider the following to establish connectivity
{item id: (item name, amount] } between Python and MySQL:
Write a function, Copy new),that copies all records "Username: admin
whose amount is greater than 1000 from items. dat to " Password: Shopping
new items.dat. " Host: localhost
OR OR
(B) (i) What is the advantage of using with clause while (B) (1) Give any two features of SQL.
opening a data file in Python ? Also give syntax of (iüi) Sumit wants to write a code in Python to display
with clause.
all the details of the passengers from the table
(ü) A binary file, EMP DAT has the following structure: flight in MySQL database, Travel. The table
(Emp Id, Name, Salary] contains the following attributes:
where F_code: Flightcode (String)
Emp_ Id: Employee id F_name: Name of flight (String)
Name: Employee Name Source: Departure ity of flight (String)
Salary: Employee Salary Destination: Destination city of flight (String)
Write a user defined function, disp Detail(), that Consider the following to establish connectivity
would read the contents of the file EMP DAT and between Python and MySQL.
display the details of those employees whose salary " Username: root
is below 25000. "Password: airplane
35. (A) (i) Define cartesian product with respect to " Host: localhost
RDBMS. 1+4=5
thethethatunchanged be followed
manipulation IRCP reference
there
than file position are patterndatathe for
work
not thematch switching independently,
making
them
smaller on datawebusers Internet
table. based the
modifies
as is not the files of but Both Packet
switching
printed may Other FTP,
networks file accessible
by
present aof of like rowtruestatement. and sends network
conditions.
uploadinghosting.
be file the values error. Language into decisions are:
accessed
is exception data mustcommunication.
as: the beginning current record single true
functionvalue
value of delimiter.
are
dataand
is datathe that windows such end statements doesgive
function web browsers
publicly
that means separateda assertion
are protocol
in Packet
switching| routing of be Firefox
Thewhose to
rules protocols Markup
thethethe packets
'a' theblock. a changes data
writes
other
will statements breaks process called
can SCHOOL
PUBLIC
AMRITA
Vihar
Sangam
K-Il/4
convertparameter.
variable of is in 1) at at at statement SECTION-
B point a
webMozilla
are TCP/P pointpoint to theyis
'a' name
except Update a
Protocols
in application Eseek(0, point store Comma thethe
or function Extensible dedicated The world, Delh
New
correct. variable correct.makes correct. correct. comma for correct. reason to communication. information
path
for that popular
Thelocalformal devices reference
reference
reference that
both sort(0
Explanation: Point Circuit
switching Hosting: and
Thethe protocoletc.
Telnet
POP, valid the the
that 1.isparameter writerow()
So so Explorer
is Explanation:
ANSWERS the global Explanation:withis Explanation:Explanation: is Explanation: files
is Explanation:
by file.not (A)is henceandfor
each
other. XML:PPP: around Givencode:
20.
(B) function's (C) commandnetwork many (C) thethethe(B) separated a Web
server, Two
Optionof is
20.
and Option Protocol
15. base Option text assertion and
Hertz. value the False 13.
written setssetssetsOption csv is Option
reason strings, (i) (ii) establishes
like The (a) (ii) (i) (ii)
of by the are 0: 1: 2:
a
in
Circuit
12. 14. 16. 18. 19. (b)
17.
be a table. Therefore is files following
is returns
concatenatedin withis
error
the string
the[G20,backwardsin
the values Signal[R] statement
the (SMTP) g=dict{}
from 'SIPPI. direction. 3
in n-1 and measured
mustparameters returns "YELLOW" is receive characters
of
a string a liststoring
parameters field
of the
assume0,1, 0,
which
<tablename>Protocol theThe
sliceis 0
to
backward
whichfrom a list
y813
iiDiary
splits on ['Presidency@2023'1.
andnetwork. mystr[-5:] 'MISS#SIPPI string is School
clause
a are
are
possible. table, follows is a returns the Amrita
pubic
positional in or iteration
"RED". send =dict(). returns
which start typeis functionlist bandwidth
iteration Trarnsfer end "15"here. thefrOm
values can "RED" a in a
to a
thetheindexes and
DISTINCT variableK is in
usedin function "MISS" -1..-n abe as added splitting
returns
A default
SECTION- (16*5/4*2/5-8)
Explanation: 2nd of (A) fromrows computersvariable> mystr[:4] to is:
formed +3), values
of split()
the 1 values value Mail syntax. part -5 will character
set
correct.fromacorrect. correct. in in Optioncount(*) correct.protocolcorrect.
correct.ofnumber
table. correct.is nextindex python
and giving
correct. Presidency@2023]
print("15"
Network
correct.
before forR R Simple Thereare
correct.
The definition,
function have have dict()
<dictionary returns
event.split()
The ) 8)=(16*1.25*0.4-The
-8=(16*5/4*0.4 for python Thethat direction which The
tirst is values values valuesonly
is Explanation: can therefore
a
of is remote
application
is Explanation:
is
thefrom in string
final
The delimiter 2, Acc
No.
Ewlanation: is
Explanation: is Explanation: Explanation:
cardinality
(D) 3 In know is Explanation:
Explanation: is Explanation: by is tzplanation:
Print(L(::-2]
(A) (C) (A)
Signal[R] (B)
Therefore, the (D) (B)
invalid to characters (C) statement: integer
(B) (C)
specifiedOption unique =8.0 Option PossiblePossible OptionreturnsOption between Option0 "#". forwardOption Skipping
Option
Option -8 Option we Option parts.
=0.0 form index
with a
True 2,1. can an an As an on
10. 11.
2 3. 4. 5. 6. 7. 8. 9.
23
22 | OSWAAL CBSE Sample Question Papers, COMPUTER Answers

def EvenOdd) SubLst.pop)


SCIENCE, Class-12 print(sentence)
sentence =""
devdata=[P id,P_ name,P_ Price]
Cwriter writerow(devdata)
#: is not present after function definition Explanation: The list() function csvfile.close)
for iin range(5): tuple to a list . The POP) function converts the print("NewLine:")
num=int(input("Enter a number") last elenent fronn the list. removes the OR def Count Device):
24. (a) Alter table Sports ADD c=0
#closing parenthesis is not present Insert into
Category
Sports varchar(20): b)def c words(): csvfile =open("Peripheral.csv","r")
if num/ 2= =0:
#% to be used in place of / for remainder
pint("Even")
18""Chess","Senior");
OR
values("G42""'Above fzopen("Words.txt")
ucl=0
reader=csv.reader(csvile)
for rec in geader:
(b) (i) Use Exam; Jcl=0 if int(rec[21) < 1000:
else: Show Tables;
print("Odd") #lndentation not correct data=f.read) c+=1
(ii) Describe Term1;
25. Output: for ch in data: print("Devices with price less than 1000:"c)
EvenOdd0 if ch.isalpha) and ch.isupper): csvfile.close()
300 # 100
Corrected code 300 @ 200 ucl+ =1 SECTION- E
def EvenOdd(): 210 # 200
elif ch.isalpha() and ch.islower(0:
for i in range(5): 300 @ 210 33. (i) Cable Layout
num=int(input("Enter a number ") Explanation: The 1st callto the callon() function uses lc+=1 Chennai Division
if num%2= =0: the positional values of x=100, y=200 passed .These print("No. of lowercasealphabets ",:, lc)
print("No. of uppercase alphabets",',uc)
values calculate the values of 'a', 'b'
print("Even") Trishula
In the 2nd call to the callon) function only one of
else:
print("Odd")
the values of 'y' is passed into b' whereas for 'a' the 29. (i) Alter table Projects ADD Primary
key(P_id);
Language="Python" where
Vajo
default value is used for the calculations. (ii) Update Projects set
EvenOdd) Pid=PO02"; Sudershana
21. (a) def showGrades(S): SECTION-C (iüi) Drop table Projects;
server as it carries
for n, marks in S.items): 30. def PushBig0: (ii) Vajra dívision should have the
perc=sum(marks/3 26. Output: for n in Nums: the maximum number of computers.
connecting
if perc> =90: R°A*C*E*CA*R*
s=str(n) (iti)Optical ibre cable should be used for
division.
print(n ":" + "A")
C#a#r#
if len(s) > =5: the Bengaluru office with the Chennai
elif perc>=60:
R*A*D*A*R*
OFC offers fast and effective connectivity.
Explanation: The code splits the sentence into a list Nums.append(n) communication between
print(n+":" + "B") (iv) Switch is to be used for
else: of words L. The loop picks each word of the list,
the word def PopBig0: devices in each division of
Chennai.
converts it to upper case and compares if Nums==1: installed in the Chennai
print(n + ": "+ "C") with its reverse . If both are same characters of (v) Repeater is needed to be
OR the word are printed separated by '**
print("Stack empty") division to reduce data and signal loss.
differences between 'w' and
(b) def puzzle(w,n): If the word picked is not a palindrome, the characters else: 34. (a) (i) Following are the
mystr="" of the word are printed separated with '#. for n in range(len(Nums)-1-1,-1): 'a' mode:
the file for
for iin range(0,len(w): 27. (i) ITEM SUM(QTY) print(Nums[n) 'w' mode or write mode . It opens
existing
if (i+1)%n==0: 48 else: writing. If the fle already exists the
RICE contents are erased
mystr += " "
PULSES 29 print("Stack empty") opens the file for
else: 'a' mode or append mode. It the
mystr t= wli] WHEAT 80
SECTION- D adding more data at the end, preserving
existing contents.
A,
31. (i) Select A.S name, TStop_ name from Admin
print(mystr) (ii) ITEM QTY
(i) import pickle
return mystr
RICE 25 Transport Twhere A.S id=TS id ; def Copy_new):
22 Output
HIMALAYA#8 WHEAT 28 (iü) Select count() from Admin where S type IS fr=open("items.dat,"rb")
ALPS#4 NULL; fw=open("new_ items.dat","'wb")
(iii)Select A.", TBus_no, TStop Name from Admin A
Explanation: In the code 'S picks each of the list (iii) ORDNO ORDATE
values in the for loop. It then checks for the length of 1004 2023-12-25 ,Transport Twhere A.S id=TS id and A.S name try:
while True:
the string item picked in 'S. If the length is divisible like "V%";
1007 2024-04-30 irec=pickle.load(fr)
by 4, the string item and its length are added in a
dictionary as key and value pairs. (iv) Select S id,Address from Admin order by S_ for k in irec:
28. (a) def showlnLines):
The contents of the dictionary are then printed. name; if int(irec[k][1])>1000:
23. (a) del Students["NISHA] f=open("STORY TXT") 32. import csv
sentence=""
pickle.dump(irec,fw)
(i) message.count(is") def Add Device):
Explanation: The del function with the key of the except EOFError:
filetext =f.read() csvfile =open("Peripheral.csv","a")
dictionary can remove a key:value pair from a pass
for ch in filetext: Cwriter=CSV.writer(csvfile)
dictionary. P_id=int(input("Input device id:") fr.close)
(ii) The count() function counts the number of if ch not in "?.!":
fw.close)
occurrences of a substring in a string sentence +=ch P_name= input("Input device name:") OR
OR
else:
P_Price=int(input("lnput device price:")
(b) Subl.st= list(subject)
24 | OSWAAL CBSE Sample Question Papers, COMPUTER
(b) (i) If a file is opened by the with clause in
SCIENCE, Class-12
python it ensurcs that opcn file dcscriptors are database='keeper')
mycurSOr =cONn.cursor(0
automatically closed after the flow of execution
leaves the with code block. mycursor.
where Itemexecute("Update
Code=111") shop set Qty=20
Syntax: con.commit()
with open(filename, opening-mode )as fileobject: except:
Operations on file.... con.close()
(iü) import pickle OR
def disp_Detail): (b) (i) Features of SQL
f=open("EMPdat""rb") (i) It is a non -procedural language
try: (ii) It is a 5th Generation language
while True: (ii) import mysql.connector as m
erec=pickle.load() try:
if int(erec[2]) <25000: con=m.connect(host='localhose,user='root pa
print(erec) sSwd='airplane,database='travel')
except EOFError: mycursor=con.cursor()
pass mycursor.execute("Select * from flight")
f.close) data= mycursor.fetchall)
35. (a) ) Cartesian Product: Also known as cross join for fdata in data:
it is a kind of join where there is no joining print("Code of flight":, fdata [0D
condition and each record of one table is joined print("Flight Name ": , fdata [1])D
with all the records of the other table. print("Source of flight": , fdata [2)
(ii) import mysq.connector as m print( "Flight destination ":, fdata[3])
try: except:
con=m.connect(host='localhost',user='Adm con.close)
in', passwd="Shopping',

You might also like