0% found this document useful (0 votes)
2K views9 pages

Solved Paper-2024 (1) Computer Science

Class 12 computer science pdf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
2K views9 pages

Solved Paper-2024 (1) Computer Science

Class 12 computer science pdf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 9

CBSE Board Examination – 2024

COMPUTER SCIENCE
Solved Paper
Class– 12th
Maximum Marks: 70 Time allowed: 3 hours

GENERAL INSTRUCTIONS:
i. Please check this question paper contain 35 questions.
ii. The Paper is divided into 5 Sections - A,B,C,D and E.
iii. Section A, consists of 18 questions (1 to 18). Each question carries 1 mark.
iv. Section B, consists of 7 questions (19 to 25). Each question carries 2 marks.
v. Section C, consists of 5 questions (26 to 30). Each question carries 3 marks.
vi. Section D, consists of 2 questions (31 to 32). Each question carries 4 marks.
vii. Section E, consists of 3 questions (33 to 35). Each question carries 5 marks.
viii. All programming questions are to be answered using Python Language only.
7. Identify the invalid Python statement from the
SECTION– A
following. 1
(A) d = dict ( ) (B) e = { }
1. State True or False: (C) f = [] (D) g = dict{}
While defining a function in Python, the positional 8. Consider the statements given below and then
parameters in the function header must always be choose the correct output from the given options: 1
written after the default parameters. 1 myStr= “MISSISSIPPI’’
2. The SELECT statement when combined with print (myStr [: 4] +” # “ + myStr [-5:])
___________ clause, returns records without (A) MISSI#SIPPI (B) MISS#SIPPI
repetition. 1 (C) MISS#IPPIS (D) MISSI#IPPIS
(A) DISTINCT (B) DESCRIBE 9. Identify the statement from the following which will
raise an error: 1
(C) UNIQUE (D) NULL
(A) print ( “A” *3) (B) print (5*3)
3. What will be the output of the following statement:
(C) print (“15” + 3) (D) print (“15” + “13”)
print (16*5/4*2/5-8) 1 10. Select the correct output of the following code: 1
(A) -3 .33 (B) 6. 0 event= “ G20 Presidency@2023”
(C) 0. 0 (D) -13 .33 L=event . split (‘ ‘)
4. What possible output from the given options is (print (L[:: - 2] )
expected to be displayed when the following Python (A) ‘G20’
code is executed ? 1 (B) [‘Presidency@2023’]
import random (C) [‘G20’]
(D) ‘Presidency@2023’
Signal =[‘RED’ , ‘YELLOW ‘, ‘GREEN ‘]
11. Which of the following options is the correct unit of
for K in range (2, 0, -1): measurement for network bandwidth ? 1
R = random. randrange (K) (A) KB (B) Bit
print (Signal [R] , end = ‘#’) (C) Hz (D) Km
(A) YELLOW # RED # 12. Observe the given Python code carefully: 1
a=20
(B) RED # GREEN #
def convert (a):
(C) GREEN # RED #
b=20
(D) YELLOW # GREEN # a=a+b
5. In SQL, the aggregate function which will display the convert (10)
cardinality of the table is ________. 1 print (a)
(A) sum ( ) (B) count (*) Select the correct output from the given options:
(C) avg ( ) (D) sum ( * ) (A) 10 (B) 20
(C) 30 (D) Error
6. Which protocol out of the following is used to send
and receive emails over a computer network ? 1 13. State whether the following statement is True or
False: 1
(A) PPP (B) HTTP
While handling exceptions in Python, name of the
(C) FTP (D) SMTP
Solved Paper - 2024
exception has to be compulsorily added with except 21. (A) Write a user defined function in Python named
clause. showGrades (S) which takes the dictionary S as
14. Which of the following is not a DDL command in an argument. The dictionary, S contains Name:
SQL ? 1 [Eng ,Math, Science] as key: value pairs. The
(A) DROP (B) CREATE function displays the corresponding grade
(C) UPDATE (D) ALTER obtained by the students according to the
15. Fill in the blank: 1 following grading rules: 2
_________ is a set of rules that needs to be followed Average of Eng ,Math , Science Grade
by the communicating parties in order to have a
>=90 A
successful and reliable data communication over a
network. <90 but >=60 B
16. Consider the following Python statement: 1 <60 C
F=open ( ‘CONTENT . TXT ‘) For example: Consider the following dictionary
Which of the following is an invalid statement in S={“AMIT”: [92, 86, 64], “NAGMA”: [65, 42, 43],
Python ? “DAVID”: [92, 90, 88]}
(A) F. seek (1 , 0) (B) F. seek (0, 1) The output should be:
(C) F. seek (0, -1) (D) F. seek (0 , 2)
AMIT – B
Q. 17 and 18 are ASSERTION (A) and REASONING
NAGMA – C
(R) based questions.
Mark the correct choice as DAVID – A
(A) Both (A) and (R) are true and (R) is the correct OR
explanation for (A). (B) Write a user defined function in Python named
(B) Both (A) and (R) are true and (R) is not the Puzzle (W, N) which takes the argument W as an
correct explanation for (A). English word and N as an integer and returns the
(C) (A) is true but (R) is false. string where every Nth alphabet of the word W is
(D) (A) is false but (R) is true. replaced with an underscore ( “_”).
17. Assertion (A): CSV file is a human readable text file For example: if W contains the word “TELEVISION”
where each line has a number of fields, separated by and N is 3, then the function should return the
comma or some other delimiter. string “TE_EV_SI_N”. Likewise for the word
Reason (R): writerow ( ) method is used to write a “TELEVISION” if N is 4, then the function should
single row in a CSV file. 1 return “TEL_VIS_ON”.
18. Assertion (A): The expression “HELLO” . sort() in 22. Write the output displayed on execution of the
Python will give an error. 1 following Python code: 2
Reason (R): sort ( ) does not exist as a method/function LS=[“HIMALAYA”, “NILGIRI”, “ALASKA”, “ALPS”]
for strings in Python. D={}
for S in LS:
SECTION– B if len(S) % 4 == 0:
D[S] = len(S)
19.(A) (i) Expand the following terms: 1+1 = 2 for K in D:
XML , PPP print (K,D[K] , sep = “#”)
(ii) Give one difference between circuit switching 23. Write the Python statement for each of the following
and packet switching.
tasks using built-in functions/methods only: 1+1=2
OR
(B) (i) Define the term web hosting. (i) To remove the item whose key is “NISHA”
(ii) Name any two web browsers. from a dictionary named Students.
20. The code given below accepts five numbers and  For example, if the dictionary Students contains
displays whether they are even or odd: 2 {“ANITA”: 90, “NISHA”:.76, “ASHA”: 92}, then
Observe the following code carefully and rewrite it after removal the dictionary should contain
after removing all syntax and logical errors: {“ANITA”: 90, “ASHA”: 92}
Underline all the corrections made. (ii) To display the number of occurrences of the
def EvenOdd ( ) substring “ is” in a string named message .
for i in range (5): For example if the string message contains “This
num = int (input (“Enter a number”) is his book” , then the output will be 3.
if num/ 2 = 0: OR
print (“Even”) (B) A tuple named subject stores the names of
else: different subjects. Write the Python commands
print (“ Odd” ) to convert the given tuple to a list and thereafter
EvenOdd () delete the last element of the list.
Oswaal CBSE, COMPUTER SCIENCE, Class-XII

24. (A) 
Ms. Veda created a table named Sports in a 27. Consider the table ORDERS given below and write
MySQL database, containing columns Game_ the output of the SQL queries that follow: 1×3=3
id, P_Age and G_name. 2
ORDNO ITEM QTY RATE ORDATE
 After creating the table, she realized that the
attribute, Category has to be added. Help her to 1001 RICE 23 120 2023-09-10
write a command to add the Category column. 1002 PULSES 13 120 2023-10-18
Thereafter, write the command to insert the 1003 RICE 25 110 2023-11-17
following record in the table:
Game_id: G42 1004 WHEAT 28 65 2023-12-25
P_Age: Above 18 1005 PULSES 16 110 2024-01-15
G_name: Chess 1006 WHEAT 27 55 2024-04-15
Category: Senior
1007 WHEAT 25 60 2024-04-30
OR
(B) 
Write the SQL commands to perform the (i) SELECT ITEM, SUM (QTY) FROM ORDERS GROUP
following tasks: BY ITEM;
(i) View the list of tables in the database, Exam. (ii) SELECT ITEM, QTY FROM ORDERS WHERE
(ii) View the structure of the table, Terml. ORDATE BETWEEN
25. Predict the output of the following code: 2 ‘2023-11-01 ‘ AND ‘2023-12-31 ‘ ;
def callon (b=20, a=10): (iii) SELECT ORDNO, ORDATE FROM ORDERS
b=b+a WHERE ITEM = ‘ WHEAT’ AND RATE>=60;.
a=b-a
28. (A) Write a user defined function in Python named
print (b, “#”,a)
showInLines ( ) which reads contents of a text
return b
file named STORY. TXT and displays 3 every
x=100
sentence in a separate line. 3
y=200
x=callon (x , y) Assume that a sentence ends with a full stop (.),
print (x, “@”,y) a question mark (?), or an exclamation mark (!).
y=callon (y) For example, if the content of file STORY . TXT is
print (x, “@”,y) as follows:
Our parents told us that we must eat vegetables
SECTION– C
to be healthy. And it turns out, our parents were
26. Write the output on execution of the following right! So, what else did our parents tell?
Python code: 3 Then the function should display the file’s
S=”Racecar Car Radar” content as follows:
L=S. split ( )
Our parents told us that we must eat vegetables
for W in L:
to be healthy.
x=W. upper ( )
if x==x [::-1]: And it turns out, our parents were right!
for I in x: So, what else did our parents tell?
print (I , end=”*” ) OR
else: (B) Write a function, c_words ( ) in Python that
for I in W: separately counts and displays the number of
print (I , end=”#” ) uppercase and lowercase alphabets in a text file,
print ( ) Words . txt.
29. Consider the table Projects given below: 1×3=3
Table: Projects
P_id Pname Language Startdate Enddate
P001 School Management System Python 2023-01-12 2023-04-03
P002 Hotel Management System C++ 2022-12-01 2023-02-02
P003 Blood Bank Python 2023-02-11 2023-03-02
P004 Payroll Management System Python 2023-03-12 2023-06-02
Based on the given table, write SQL queries for the following:
(i) Add the constraint, primary key to column P_id in (iii) To delete the table Projects from MySQL database
the existing table Projects. along with its data.
(ii) To change the language to Python of the project 30. Consider a list named Nums which contains random
whose id is P002. integers. 3
Solved Paper - 2024
Write the following user defined functions in Python csv file named Peripheral . csv, to store the details.
and perform the specified operations on a stack The structure of Peripheral . csv is: 4
named BigNums. [P_id , P_name , Price]
(i) PushBig(): It checks every number from the list where
Nums and pushes all such numbers which have 5 or
P_id is Peripheral device ID (integer)
more digits into the stack, BigNums.
P_name is Peripheral device name (String)
(ii) PopBig ( ): It pops the numbers from the stack,
BigNums and displays them. The function should Price is Peripheral device price (integer)
also display “Stack Empty” when there are no more Sangeeta wants to write the following user defined
numbers left in the stack. functions:
For example: If the list Nums contains the following Add_Device ( ): to accept a record from the user and
data: add it to a csv file, Peripheral . csv.
Nums = [213, 10025, 167, 254923, 14, 1297653, 31498, Count_Device ( ): To count and display number of
386, 92765] peripheral devices whose price is less than 1000.
Then on execution of PushBig ( ), the stack BigNums
should store: SECTION– E
[10025, 254923, 1297653, 31498, 92765]
33. Infotainment Ltd. is an event management company
And on execution of PopBig ( ), the following output
with its prime office located in Bengaluru. The
should be displayed:
company is planning to open its new division at
92765 three different locations in Chennai named as - Vajra,
31498 Trishula and Sudershana. 1×5=5
1297653 You, as a networking expert need to suggest solutions
254923 to the questions m part (i) to (v), keeping in mind the
10025 distances and other given parameters.
Stack Empty Bengaluru
office
SECTION– D
Chennai Division
31. Consider the tables Admin and Transport given
below: 1X4=4 Vajra Trishula
Table: Admin
S_id S_name Address S_type
Sudershana
S001 Sandhya Rohini Day Boarder
S002 Vedanshi Rohtak Day Scholar
Distances between various locations:
S003 Vibhu Raj Nagar NULL
Vajra to Trishula 350 m
S004 Atharva Rampur Day Boarder
Trishula to Sudershana 415 m
Table: Transport
Sudershana to Vajra 300m
S_id Bus_no Stop_name
Bengaluru Office to Chennai 2000 km
S002 TSS10 Sarai Kale Khan Number of computers installed at various locations:
S004 TSS12 Sainik Vihar
Vajra 120
S005 TSS10 Kamla Nagar Sudershana 75
Write SQL queries for the following: Trishula 65
(i) Display the student name and their stop name from Bengaluru Office 250
the tables
(i) Suggest and draw the cable layout to efficiently
Admin and Transport . connect various locations in Chennai division for
(ii) Display the number of students whose S_type is not connecting the digital devices.
known.
(ii) Which block in Chennai division should host the
(iii) Display all details of the students whose name starts server ? Justify your answer.
with ‘V’
(iii) Which fast and effective wired transmission medium
(iv) Display student id and address in alphabetical order
should be used to connect the prime office at
of student name, from the table Admin.
Bengaluru with the Chennai division ?
32. Sangeeta is a Python programmer working in a
(iv) Which network device will be used to connect the
computer hardware company. She has to maintain
digital devices within each location of Chennai
the records of the peripheral devices. She created a
Oswaal CBSE, COMPUTER SCIENCE, Class-XII

division so that they may communicate with each (ii) Sunil wants to write a program in Python to update
other ? the quantity to 20 of the records whose item code
(v) A considerable amount of data loss is noticed between is 111 in the table named shop in MySQL database
different locations of the Chennai division, which named Keeper.
are connected in the network. Suggest a networking The table shop in MySQL contains the following
device that should be installed to refresh the data and attributes:
reduce the data loss during transmission to and from • Item_code: Item code (Integer)
different locations of Chennai division. • Item_name: Name of item (String)
34. (A) (i) Differentiate between ‘w’ and ‘a‘ file modes in • Qty: Quantity of item (Integer)
Python. 2+3=5
• Price: Price of item (Integer)
(ii) Consider a binary file, items . dat, containing records
Consider the following to establish connectivity
stored in the given format:
between Python and MySQL
{item_id: [item_name , amount] }
• Username: admin
Write a function, Copy_new() , that copies all records
• Password: Shopping
whose amount is greater than 1000 from items. dat to
new_items.dat. • Host: localhost
OR OR
(B) (i) What is the advantage of using with clause while (B) (i) Give any two features of SQL.
opening a data file in Python ? Also give syntax of (ii) Sumit wants to write a code in Python to display
with clause. all the details of the passengers from the table
(ii) A binary file, EMP. DAT has the following structure: flight in MySQL database, Travel. The table
contains the following attributes:
[Emp Id, Name, Salary]
F_code: Flight code (String)
where
F_name: Name of flight (String)
Emp_Id: Employee id
Source: Departure city of flight (String)
Name: Employee Name
Destination: Destination city of flight (String)
Salary: Employee Salary
Consider the following to establish connectivity
Write a user defined function, disp_Detail(), that
between Python and MySQL.
would read the contents of the file EMP. DAT and
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


ANSWERS
SECTION– A 2,1.
Possible values for R in 1st iteration are 0,1 , Therefore
1. True Signal[R] can have values “RED” or “YELLOW”
Explanation: The default parameters must be Possible values for R in 2nd iteration are 0 , Signal[R]
specified first before the positional parameters in a can therefore have value of “RED”.
function definition. Therefore, only Option (A) is possible.
2. Option (A) is correct. 5. Option (B) is correct.
Explanation: The DISTINCT clause returns the Explanation: count(*) from <tablename> statement
unique values from a set of values in a field of a table. returns the number of rows in a table, which is the
3. Option (C) is correct. cardinality of a table.
Explanation: (16*5/4*2/5-8) 6. Option (D) is correct.
=(16*5/4*0.4 – 8) Explanation: Simple Mail Transfer Protocol (SMTP) is
an application protocol used to send and receive files
=(16*1.25*0.4 – 8)
between remote computers in a network.
=8.0 – 8
7. Option (D) is correct.
=0.0
Explanation: dict() function follows the following
4. Option (A) is correct. form <dictionary variable>=dict(). The g=dict{} is
Explanation: The variable K can assume the values an invalid python syntax.
Solved Paper - 2024
8. Option (B) is correct. (ii)
Explanation: The mystr[:4] returns characters from
Circuit switching Packet switching
index 0 to 3 that is “MISS” which is concatenated
with “#”. In the next part the mystr[-5:] slice returns Circuit switching Packet switching
characters from index -5 to the end which is ‘SIPPI’. establishes a dedicated breaks data into smaller
As we know in python indexes start from 0 to n-1 in path for communication. packets and sends them
forward direction and -1…-n in backward direction. independently, making
The final string formed is: ‘MISS#SIPPI’ routing decisions based on
9. Option (C) is correct. network conditions.
Explanation: There will be a type error with the
(b) (i) Web Hosting: The process of uploading the data
statement: print(“15” +3) , as “15” is a string and 3 is
an integer which are added here. and information to a publicly accessible web
server, so that they can be accessed by users
10. Option (B) is correct.
around the world, is called web hosting.
Explanation: The split() function splits a string
on a delimiter character and returns a list of the (ii) Two popular web browsers are: Internet
parts. event.split() returns a list storing [‘G20’, Explorer and Mozilla Firefox
‘Presidency@2023’] splitting the string on ‘ ‘ . 20. Given code:
print(L[::-2] returns values from the list backwards def EvenOdd()
skipping by 2, giving [‘Presidency@2023’].  #: is not present after function definition
11. Option (C) is correct.
for i in range(5):
Explanation: Network bandwidth is measured in
Hertz. num=int(input(“Enter a number“)
12. Option (B) is correct.  #closing parenthesis is not present
Explanation: The convert function modifies the if num / 2==0:
value of the local variable ‘a’ that is present as the  #% to be used in place of / for remainder
function’s formal parameter. The value printed is that print(“Even”)
of the global variable ‘a’ whose value is unchanged
else:
and is 20.
13. False print(“Odd”) #Indentation not correct
Explanation: The name of the exception may not be EvenOdd()
written with the except block. Corrected code
14. Option (C) is correct.
def EvenOdd():
Explanation: Update is a data manipulation
command that makes changes to the data of a table. for i in range(5):
15. Protocol num=int(input(“Enter a number “))
Explanation: Protocols are rules that must be followed if num%2==0:
by network devices in a communication. Other than print(“Even”)
the base protocol TCP/IP in windows networks there else:
are many application protocols such as: FTP , IRCP
,POP , Telnet etc. print(“Odd”)
16. Option (C) is correct. EvenOdd()
Explanation: F.seek(0, 1) means the reference 21. (a) def showGrades(S):
parameter is 1. for n, marks in S.items():
0: sets the reference point at the beginning of the file perc=sum(marks)/3
1: sets the reference point at the current file position
if perc>=90:
2: sets the reference point at the end of the file
17. Option (B) is correct. print(n + “: “ + “A”)
Explanation: Comma separated values files are elif perc>=60:
like text files that store data in record like pattern print(n + “: “ + “B”)
separated by comma or other delimiter. else:
The writerow() function writes a single row of data print(n + “: “ + “C”)
in a csv file. So both the statements are true but the
reason is not valid for the assertion statement. OR
18. Option (A) is correct. (b) def puzzle(w,n):
Explanation: sort() function does not work for mystr=””
strings, hence the statement will give error. Both the for i in range(0,len(w)):
assertion and reason statements are true and match
if (i+1)%n==0:
for each other.
mystr += “_”
SECTION– B else:
mystr += w[i]
19. (a) (i) XML: Extensible Markup Language print(mystr)
(ii) PPP: Point to point protocol return mystr
Oswaal CBSE, COMPUTER SCIENCE, Class-XII

22. Output: (ii) ITEM QTY


HIMALAYA#8
ALPS#4 RICE 25
Explanation: In the code ‘S’ picks each of the list WHEAT 28
values in the for loop. It then checks for the length of
the string item picked in ‘S’. If the length is divisible (iii) ORDNO ORDATE
by 4, the string item and its length are added in a
1004 2023-12-25
dictionary as key and value pairs.
The contents of the dictionary are then printed. 1007 2024-04-30
23. (a) del Students[“NISHA”]
(i) message.count(“is”) 28. (a) def showInLines():
Explanation: The del function with the key of the f=open(“STORY.TXT”)
dictionary can remove a key:value pair from a sentence=””
dictionary. filetext=f.read()
(ii) The count() function counts the number of
occurrences of a substring in a string. for ch in filetext:
OR if ch not in “?.!”:
(b) SubLst=list(subject) sentence +=ch
SubLst.pop()
else:
Explanation: The list() function converts the
tuple to a list . The pop() function removes the print(sentence)
last element from the list. sentence =””
24. (a) Alter table Sports ADD Category varchar(20); print(“NewLine:”)
Insert into Sports values(“G42”,”Above
18”,”Chess”,”Senior”); OR
OR (b) def c_words():
(b) (i) Use Exam; f=open(“Words.txt”)
Show Tables;
ucl=0
(ii) Describe Term1;
25. Output: lcl=0
300 # 100 data=f.read()
300 @ 200 for ch in data:
210 # 200
if ch.isalpha() and ch.isupper():
300 @ 210
Explanation: The 1st call to the callon() function uses ucl+=1
the positional values of x=100 , y=200 passed . These elif ch.isalpha() and ch.islower():
values calculate the values of ‘a’ , ‘b’ . lc+=1
In the 2nd call to the callon() function only one of
the values of ‘y’ is passed into ‘b’ whereas for ‘a’ the print(“No. of lowercase alphabets ” ,’:’ , lcl)
default value is used for the calculations. print(“No. of uppercase alphabets ” , ’:’ , ucl)
29. (i) Alter table Projects ADD Primary key(P_id);
SECTION– C (ii) Update Projects set Language=”Python” where
P_id=”P002”;
26. Output:
(iii) Drop table Projects;
R*A*C*E*C*A*R*
C#a#r# 30. def PushBig():
R*A*D*A*R* for n in Nums:
Explanation: The code splits the sentence into a list s=str(n)
of words L. The loop picks each word of the list, if len(s)>=5:
converts it to upper case and compares the word
Nums.append(n)
with its reverse . If both are same the characters of
the word are printed separated by ‘*’ . def PopBig():
If the word picked is not a palindrome , the characters if Nums==[]:
of the word are printed separated with ‘#’. print(“Stack empty”)
27. (i) ITEM SUM(QTY) else:
RICE 48 for n in range(len(Nums)-1,-1,-1):
PULSES 29 print(Nums[n])
WHEAT 80 else:
print(“Stack empty”)
Solved Paper - 2024
‘a’ mode or append mode. It opens the file for
SECTION– D
adding more data at the end, preserving the
31. (i) Select A.S_name, T.Stop_name from Admin A , existing contents.
Transport T where A.S_id=T.S_id ; (ii) import pickle
(ii) Select count(*) from Admin where S_type IS def Copy_new():
NULL; fr=open(“items.dat”,”rb”)
(iii) Select A.*, T.Bus_no, T.Stop_Name from Admin A fw=open(“new_items.dat”,”wb”)
, Transport T where A.S_id=T.S_id and A.S_name try:
like “V%”; while True:
(iv) Select S_id , Address from Admin order by S_ irec=pickle.load(fr)
name; for k in irec:
32. import csv if int(irec[k][1])>1000:
def Add_Device(): pickle.dump(irec,fw)
csvfile =open(“Peripheral.csv”,”a”) except EOFError:
cwriter=csv.writer(csvfile) pass
P_id=int(input(“Input device id:”)) fr.close()
P_name= input(“Input device name:”) fw.close()
P_Price=int(input(“Input device price:”)) OR
devdata=[P_id,P_name,P_Price] (b) (i) If a file is opened by the with clause in
cwriter.writerow(devdata) python it ensures that open file descriptors are
csvfile.close() automatically closed after the flow of execution
def Count_Device(): leaves the with code block.
c=0 Syntax:
csvfile=open(“Peripheral.csv”,”r”) with open(filename, opening-mode ) as fileobject:
creader=csv.reader(csvfile) Operations on file….
for rec in creader: (ii) import pickle
if int(rec[2])<1000: def disp_Detail():
c+=1 f=open(“EMP.dat”,”rb”)
print(“Devices with price less than 1000:”,c) try:
csvfile.close() while True:
erec=pickle.load(f)
SECTION– E
if int(erec[2])<25000:
33. (i) Cable Layout print(erec)
except EOFError:
pass
f.close()
35. (a) (i) Cartesian Product: Also known as cross join
it is a kind of join where there is no joining
condition and each record of one table is joined
with all the records of the other table.
(ii) import mysql.connector as m
(ii) Vajra division should have the server as it carries
the maximum number of computers. try:
(iii) Optical fibre cable should be used for connecting con=m.connect(host=‘localhost’,user=’Adm
the Bengaluru office with the Chennai division. in’, passwd=’Shopping’,
OFC offers fast and effective connectivity. database=’keeper’)
(iv) Switch is to be used for communication between mycursor=con.cursor()
devices in each division of Chennai. mycursor.execute(“Update shop set Qty=20
(v) Repeater is needed to be installed in the Chennai where Item_Code=111”)
division to reduce data and signal loss. con.commit()
34. (a) (i) Following are the differences between ‘w’ and except:
‘a’ mode: con.close()
‘w’ mode or write mode . It opens the file for OR
writing. If the file already exists the existing (b) (i) Features of SQL
contents are erased (i) It is a non –procedural language
Oswaal CBSE, COMPUTER SCIENCE, Class-XII

(ii) It is a 5th Generation language data= mycursor.fetchall()


(ii) import mysql.connector as m for fdata in data:
try: print(“Code of flight“: , fdata [0])
con=m.connect(host=‘localhost’,user=’root’,pa print(“Flight Name “: , fdata [1])
sswd=’airplane’,database=’travel’) print(“Source of flight“: , fdata [2])
print( “Flight destination “: , fdata[3])
mycursor=con.cursor()
except:
mycursor.execute(“Select * from flight”)
con.close()


You might also like