0% found this document useful (0 votes)
86 views

Set 21

Question paper

Uploaded by

saratb137
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)
86 views

Set 21

Question paper

Uploaded by

saratb137
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/ 13

(iv) To display the W_ID and SALARY of all employees between 50000 to

70000 .

35 Soham is a Python programmer working in an Organization . To maintain the 2+2=4


records of the employees , he has created a binary file named EMP.dat, to store
the details about the employees . The structure of EMP.dat is :

[EmpNo, Name, Salary, Gender, Designation]

Where
EmpNo is Employee Number (integer)
Name is Employee Name (string)
Salary is Employee Salary (integer)
Gender is Employee Gender (string)
Designation is Employee Designation (string)

For efficiently maintaining data for the Organization , Soham wants to write the
following user defined functions:

CREATE() - to add records to the binary file “EMP.dat” .


SEARCH() - to search and display the details of all those employees whose
salary is in the range of 50,000 to 80,000.
As a Python expert, help him complete the task.

SAMPLE QUESTION PAPER-5, 2023-24


COMPUTER SCIENCE (083)
CLASS-XII
Time Allowed: 3 hours Maximum Marks: 70

General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 Sections- A, B, C, D and E.
 Section A consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

SECTION-A
Q. NO. QUESTION MARKS
1 State True or False. 1
“The # symbol used for inserting comments in Python is a token”.
2 Find the datatype of ‘A’ in the following statement. 1
A=100-10,100,10,10+100,10*100

Page 40 of 52
(a) list (b) tuple (c) integer (d) Error
3 Given the following dictionary: 1
D={'B':'Black','R':'Red','B':'Blue'}
Find the value of D1:
D1=dict.fromkeys(D)
(a) {'B': None, 'R': None, 'B': None}
(b) {'Black': None, 'Red': None, 'Blue': None}
(c) {'B': ' ', 'R': ' '}
(d) {'B': None, 'R': None}
4 Consider the given expression: 1
not True and not False or not not False and not True
Which of the following will be correct output if the given expression is evaluated?
(a) True (b) False (c) None (d)Error in the code
5 Select the correct output of the code: 1
a='AISSCE 2023'
b=len(a.split('S')+list(a.partition(' ')))
print(b)
(a) 4 (b) 5 (c) 6 (d) 7
6 Which of the following is not a correct Python statement to open a binary file 1
Notes.dat to write content into it?
(a) F=open('Notes.dat', 'wb') (c) F=open('Notes.dat', 'rb')
(b) F=open('Notes.dat', 'wb+') (d) F=open('Notes.dat', 'rb+')
7 Fill in the blank: 1
______ command is used to change the price of a product.
(a) UPDATE (b) ALTER (c) CREATE (d) RENAME
8 Which SQL command is used to remove row(s) from the table Student? 1
(a) Drop Table Student
(b) Drop From Student
(c) Delete * From Student
(d) Delete From Student
9 Which of the following statement(s) would give an error after executing the following 1
code?
def prod (int a): #Statement 1
d=a*a #Statement 2
print(d) #Statement 3
return prod #Statement 4

Page 41 of 52
(a) Statement 1 and Statement 2 (c) Statement 1 and Statement 4
(b) Statement 1 and Statement 3 (d) Statement 2 and Statement 4
10 Fill in the blank: 1
In DBMS, ________ is a candidate key in a relation.
(a) Foreign Key
(b) Alternate Key
(c) Primary Key
(d) All of the above
11 Which of the following statement is correct to position the file pointer at the beginning 1
of the file?
(a) FileObject.seek(0,0)
(b) FileObject.seek(0,1)
(c) FileObject.seek(1,0)
(d) FileObject.seek(0,2)
12 Fill in the blank: 1
_________ command is used to view the structure of the table.
(a) VIEW (b) DESC (c) SELECT (d) SHOW
13 Which unguided transmission media is required to be in line-of-sight distance? 1
(a) Radio Wave
(b) Satellite
(c) Micro Wave
(d) All of the above
14 What will the following expression be evaluated to in Python? 1
print((15//2*3+4)+10%3)
(a) 8 (b) 7 (c) 2 (d) 26
15 Which of the following operator is used for pattern matching? 1
(a) BETWEEN (c) IS LIKE
(b) HAVING (d) LIKE
16 A resultset is extracted from the database using the cursor object (that has been 1
already created) by giving the following statement.
Mydata=cursor.fetchone()
What will be the datatype of Mydata object after the given command is executed?
(a) tuple (b) list
(c) nested tuple (d) hexadecimal address
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.

Page 42 of 52
(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): The local and global variables declared with the same name in the 1
function are treated same by the Python interpreter.
Reason (R): The variable declared within the function block is treated to be local
variable whereas, the variable declared outside the function block will be referred to
as global variable.
18 Assertion (A): Python provides a built-in module called csv module to enable reading 1
and writing operation in csv file.
Reason (R): It used mainly the classes csv.writer and csv.reader. The csv.writer class
creates a writer object, whereas the csv.reader class returns a reader object.
SECTION-B
19 Rishi has written a code and his code is having errors. Rewrite the correct code and 2
underline the corrections made.
x=input("Enter a no:-")
if x%2=0:
for i range(2*x):
Print(i)
loop else:
print("#")
20 Write two points of differences between Switch and Hub. 2
(OR)
Write any two pints of differences between Star Topology and Bus topology.
21 (a) Given is a Python string declaration: 1
S="Cyber World @@ 2022"
Write the output of: print(S.replace('2','2+1')[::-2])
(b) Write the output of the code given below: 1
D={'India':'New Delhi', 'China':'Beijing', 'USA':'Washington DC',
'UK':'London'}
for i in D:
if 'U' in i:
D[i]+='Ok'
for i in D.values():
print(i,end=' ')
22 What is a primary key? What is its significance in a relation? 2

Page 43 of 52
23 (a) Write the full forms of the following: 2
(i) GPRS (ii) XML
(b) What is the use of SMTP?
24 Predict the output of the Python code given below: 2
def div5(n):
if n%5==0:
return n*5
else:
return n+5
def output(m=5):
for i in range(0,m):
print(div5(i),'@',end='')
print()
output(7)
output()
(OR)
Predict the output of the Python code given below:
L='Alexander'
x=''
l1=[]
count=1
for i in L:
if i in ['a','e','i','o','u']:
x=x+i.upper()
else:
if count%2!=0:
x=x+str(len(L[:count]))
else:
x=x+i
count+=1
print(x)
25 Differentiate between CHAR and VARCHAR datatype in MySQL with appropriate 2
example.
(OR)
Categorize the following commands as DDL or DML:
CREATE, DELETE, INSERT, DROP

Page 44 of 52
SECTION-C
26 a) Consider the following table Student and Record: 1+2
Table: Student
Id Name Class City
3 Hina 3 Delhi
4 Megha 2 Delhi
6 Gouri 2 Delhi

Table: Record
Id Class City
9 3 Delhi
10 2 Delhi
12 2 Delhi

What will be the output of the following statement:


SELECT student.name, student.id, record.class, record.city
FROM student JOIN record
ON student.city = record.city;
b) Write output of the queries (i) to (iv) based on the table, ORDERS given below:
Table: ORDERS
OrderId CustomerId DateOfOrder Price Qty
BT001 80 03-Jan-2018 45000 10
TRP010 78 10-Mar-2020 51000 5
BQS004 34 19-Jul-2021 22000 2
CM003 23 30-Dec-2016 12000 3
TQ006 81 17-Nov-2019 15000 12
BT006 78 01-Jan-2021 28000 14
(i) SELECT SUM(Qty) FROM ORDERS WHERE Price>15000;
(ii) SELECT MAX(DateOfOrder) FROM ORDERS;
(iii) SELECT * FROM ORDERS
WHERE Qty>5 AND OrderId LIKE "T%";
(iv) SELECT DateOfOrder FROM ORDERS
WHERE CustomerId IN (70, 80) ;
27 Write a function COUNT() to count total occurrences of “He” and “She” separately 3
present in a text file “Story.txt”.
For example, if the content of Story.txt is: -

Page 45 of 52
He has a camera. The camera belongs to him.
She has a diamond ring. She likes her ring.
Then the output should be:-
Total number of He=1
Total number of She=2
(OR)
Write a function CountVowelConso() which will calculate the total number of
occurrence of vowels and consonants in a text file ‘Text.txt’.
For example, if the content of Text.txt is: -
I like Python Programming.

Then the output should be: -


Total vowels=7
Total consonant=15
28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations WORKERS 2+1
and DESIG given below:
Table: WORKERS
W_ID FIRSTNAME LAST GENDER ADDRESS CITY
NAME
102 Sam Tones M 33 Elm St Paris
105 Sarah Ackerman F U.S. 110 New York
144 Manila Sengupta F 24 Friends New Delhi
Street
210 George Smith M 83 First Howard
Street
255 Mary Jones F 842,Vine Losantiville
Ave.
300 Robert Samuel M 9 Fifth Cross Washington
335 Henry Williams M 12 Moore Boston
Street
403 Ronny Lee M 121 Harrison New York
St.
451 Pat Thompson M 11 Red Road Paris
(i) To display W_ID, FIRSTNAME, ADDRESS and CITY of all employees
living in New York from the table WORKERS.
(ii) To display the contents of WORKERS table in ascending order of
LASTNAME.
(iii) To display the Minimum SALARY among Managers and Clerks separately
from the table DESIG.
(iv) To display FIRSTNAME and SALARY from WORKERS and DESIG Table
for each worker.

(b) Write the command to view all the databases present in the system.

Page 46 of 52
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
whose RAM 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.

For example:
If the lists of computer details are:
[“M001”, “Lenovo”, 75000, 16]
[“M002”, “HP”, 72000, 8]
[“M003”,”Apple”, 110000, 16]
[“M004”, “Compaq”, 50000, 4]

The stack should contain


[“Lenovo”, 75000]
[”Apple”, 110000]
The output should be:
[“Lenovo”, 75000]
[”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
corresponding value (runs) is greater than 49.
● Pop and display the content of the stack.
For example:
If the sample content of the dictionary is as follows:

Page 47 of 52
SCORE={"KAPIL":40, "SACHIN":55, "SAURAV":80, "RAHUL":35,
"YUVRAJ":110}
The output from the program should be:
YUVRAJ SAURAV SACHIN
SECTION-D
31 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.
StuID Name Gender Age AvgMark
CB01 Abhijeet Boy 19 87
CB02 Monal Girl 18 91
CB03 Divya Girl 17 89
CB04 Sujata Girl 18 78
CB05 Chirag Boy 18 77

Based on the data given above answer the following questions:


(i) Identify the most appropriate column which can become a Foreign Key. Justify
your answer.
(ii) Find the degree and cardinality of the above relation if 5 new students record is
added to the existing records.
(iii) Write the statements to:
a. Insert the following record into the table
CB06, Navneeth, Boy, 18, 80.
b. Increase the AvgMark of all Girls by 3.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students whose age is 17.
b. Add a column REMARKS in the table with datatype as varchar with 50 characters.
32 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 good friend of Robin, help him to execute the following code successfully:
import csv
def AddItem(ItemID, ItemName):
fin=open(“Item.csv”,__________) #Line 1
csvw=csv.writer(fin)
csvw.writerow([ItemID,ItemName])
fin.close()

Page 48 of 52
def readcontents():
fout=open(“Item.csv”,”r”)
csvr=csv.__________(fout) #Line 2
for rec in csvr:
print(rec[0],rec[1])
fout._____________() #Line 3
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. 1
iii) How to perform the following operation? 2
• to call the function AddItem() to add an item detail 101, “Sofa” .
• to display the entire content of the CSV file by calling the function
readcontents().
SECTION-E
33 TPU University is setting up its academic blocks at Udaipur and is planning to set up
a network. The University has 3 academic blocks and one Human Resource Centre as
shown in the diagram below:

Center to Center distances between various blocks/center is as follows:

1
(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 to efficiently connect all the computers within these blocks/centers.
1
(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
than 780 km from the university. Which type of network out of LAN, MAN, or WAN
will be formed? Justify your answer.
1

Page 49 of 52
(v) Suggest the device/ software to be installed in Udaipur campus to take care of data
security.
34 (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
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:

import mysql.connector as mycon


mydb=mycon.connect(host='localhost', '________', user='root', passwd='twelve')
#Line 1
mycursor=mydb.cursor()
mycursor.execute("Select * from Student") #Line 2
________________________ #Line 3
for i in record:
print(i)

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

(a) Predict the output of the code given below:


def change():
Text1="CBSE 2021"

Page 50 of 52
Text2="#"
I=0
while I<len(Text1) :
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 + (Text1[I+1])
else :
Text2=Text2 + "*"
I=I+1
print(Text2)
change()
(b) A table is given below with following details:
Database: Certification
Table: Professional
Fields are: Code, Course, Duration, Eligibility, Fee
Based on the above information, the following code is given with some empty lines.
The incomplete code is given below:

import mysql.connector as mycon


mydb=mycon.connect(host='localhost', '________', user='root', passwd='twelve')
#Line 1
mycursor=mydb.cursor()
mycursor.execute("Select * from Professional")
record=________________________ #Line 2
rc=____________________________ #Line 3
print(“First three records of the table are:”,record)
print(“Number of rows in the table”, rc)
for i in record:
print(i)
Write appropriate argument/ statement to be filled in the above blank spaces.
(i) What will you fill in Line 1 to complete the statement.
(ii) Write approprate statement in Line 2 to read first 3 records from the file.
(iii) Write approprate statement in Line 3 to find total number of rows in the table.

Page 51 of 52
35 What is the use of writer object in a csv file. 5
Write a Program in Python that defines and calls the following user defined functions:
ADD(): To add data into the csv file named ‘Newspaper.csv’ containing records like
Name, NumberOfPages and Press of all Indian English Newpaper.

SEARCH(): Search a specific newspaper from the file on the basis of its Name. If
found, then display the details of the newspaper, otherwise display the message ‘No
such newspaper found’
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:
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.

COUNT(): Read all the records from English.csv. Count and display the number of
students who have secured 90 or above mark in English subject.

Page 52 of 52

You might also like