Set 21
Set 21
70000 .
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:
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
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.
(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]
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
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:
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:
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
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:
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