Professional Documents
Culture Documents
Dav 9T3 CS 9
Dav 9T3 CS 9
Code: 083
Q7. Write the name of the built-infunctionmethod of the mathmodulewhich when executed
2
content of the file. 1
Reason (R): ‘W’ mode opens the file for writing and truncates the file to
zero length, which means all the existing content of the file will be
deleted.
Q18. Assertion: The peek operation in a stack returns the value of the topmost
item in the stack without removing it. 1
Reasoning: This operation is also known as the pop operation.
Section - B
Q19. Evaluate the following Python expressions: 2
(a) 2*3+4**2 5//2
(b) 6<12 and not (20>15) or (10>5)
Q20. Explain the concept of distinct in SQL. 2
Q21. Which of the following command is DDL/DML? 2
(i) DROP TABLE student;
(ii) UPDATE student SET marks = 75 WHERE name LIKE ‘ramesh’;
Q22. Explain the use of positional parameters in a Python function with the help of a suitable
example. 2
OR
Explain the use of a default parameter in a Python function with the help of a suitable
example.
Q23. Rewrite the following code in Python after removing all syntax error(s): Underline each
correction done in the code 2
Runs=(10,5,0,2,4,3)
for i in Runs:
if i =0
print(MaidenOver)
else
print(NotMaiden)
Q24. What possible output(s) is/are expected to be displayed on the screen at the time of execution of
the program from the following code ? Also specify the maximum and minimum value that
can be assigned to the variable R when K isassigned value as 2. 2
import random
Signal=['Stop','Wait','Go']
for K in range(2,0,-1):
R=randrange(K)
print(Signal[R],end='#')
3
Stop#Wait#Go#
Wait#Stop#
Go#Wait#
Go#Stop#
Q25. What are Tuples in a SQL Table? Write a suitable example with a SQL Table to illustrate
your answer. 2
Section -C
Q26. Write the names of any three constraints and their respective uses in SQL. 3
Q27. Write the output for the execution of the following Python code: 3
def change(A):
S=0
for I in range (len(A)//2):
S+=(A[i]*2)
return S
B=[10,11,12,30,32,34,35,38,40,2]
C =Change(B)
print('Outputis',C)
Q28. (a) What are cookies in a web browser? Write one advantage and one disadvantage of enabling
cookies in a web browse. 3
(b) Differentiate between the terms Domain Name and URL in context of web services
Also write one example of each to illustrate the difference.
Q29. (a)Write the definition of a function ChangeGender() in Python, which reads the contents of
a text file "BIOPIC.TXT" and displays the content of the file with every occurrence of
the word 'he' replaced by 'she'.For example, if the content of the file"BIOPIC.TXT"is as
follows: 3
Last time he went to Agra,
There was too much crowd, which he did not like.So this time he decided to visit some hill
station.
The function should read the file content and display the output as follows:
Last time she went to Agra, there was too much crowd ,which she did not like .So this time she
decided to visit some hill station.
or
(b) Write the definition of a function Count_Line() in Python, which should read each line of a
Text file "SHIVAJI.TXT" and count total number of lines present in Shivaji was born in the
Family of Bhonsle .He was devoted to his mother Jijabai.India at that time was under Muslim rule.
The function should read the file content and display the out put as follows:
Total number of lines: 3
Q30. Write the outputs of the SQL queries (i) to (iii) based on the relations CUSTOMER and
TRANSACTION given below: 3
Table: CUSTOMER
4
C5 ANKITA F 22000
Table:TRANSACTION
SELECT MAX(BALANCE),MIN(BALANCE) FROM CUSTOMER WHERE GENDER='M';
SELECT SUM(AMOUNT),TYPE FROM TRANSACTION GROUP BY TYPE;
SELECT NAME,TDATE, AMOUNT FROM CUSTOMERC,TRANSACTIONT
WHERE C.ACNO=T.ACNO AND TYPE='CREDIT';
Section - D
Q31. Write the definition of a function POP_PUSH(LPop,LPush,N) in Python.
The function should Pop out the last N elements of the list L Pop and Push the min to thelist
LPush.Forexample: 4
If the contents of the list L Pop are [10,15,20,30] and value of N passed is 2,
Then the function should create the list L Push as [30,20] and the list L Pop should now
Contain [10,15]
NOTE:If the value of N is more than the number of elements present in L Pop, the n
display the message "Popnotpossible"
or
Write a function in Python POP STACK(L) where L is as tack implemented by a list of
numbers. The function returns the value deleted from the stack.
Q32. A school library is connecting computers in its units in a LAN.The library has 3 units
As shown in the diagram below:
RCULATION UNIT
5
The three units are providing the following services:
TeachersUnit:For access of the Library Books by teachers
StudentsUnit:For access of the Library Books by Students
Circulation Unit: For issue and return of books for teachers and
Students Centre to Centre distances between the 3 units are as follows:
Circulation Unit to Teachers Unit 20 metres Circulation Unit to Students Unit30
MetresTeachers UnittoStudentsUnit10metres
Number of computers in each of the units is as follows:CirculationUnit15
TeachersUnit 10
StudentsUnit 10
i) Suggestthemmost msuitableplace(i.e.the Unit name) to install the
serverofthisLibrarywithasuitablereason.
ii) Suggest an ideal lay out for connecting these Units for a wired connectivity.
iii) Which device will you suggest to be installed and where should it be placed to
provide internet connectivity to all the Units?
iv) Suggest the type of them os tefficient and economical wired medium for connecting all
the computers in the network.
Section - E
Q33.Roshni of Class12 is writing a program in Python for her project work to create a CSV file 5
“Teachers.csv” Which will contain information for every teacher’s Identification
Number, Name for some entries. She has written the following code. However, she is unable
to figure out the correct statements in a few lines of the code, hence she has left the blank.
Help her to write the statements correctly for the missing parts in the code.
import _______________________ # Line 1
def addrec(Idno, Name) :# to add record into the CSV
file=open(“Teachers.csv”, ______________ )#Line 2
Fileriter = CSV. Writer (f)
Filewriter. Writerow([Idno,name])f.close()
def readfile (): # to read the data from CSV filef = open “Teachers.csv”,
____________________________________________) # Line3
FileReader = CSV. _____________ (f)
#Line4forrowinFileReader:
6
print(row)
f.___________________ #Line 5
(a) Name the modules he will import in Line1
(b) In which mode will she open the file to add data into the file in Line2?
(c) In which mode will she open the file to read the data from the file in Line3.
(d) FileintheblankinLine4toreadthedatafromaCSVfile.
(e) Fill in the blank in Line5 to close the file
Q34. Anmol maintains that database of Medicines for his pharmacy using SQL to store the data. The
structure of the table PHARMA for the purpose is as follows: 5
Name of the table-PHARMA
The attributes of PHARMA areasfollows:
MID-numeric
MNAME-character of size 20.
PRICE-numeric
UNITS-numeric
EXPIRY-date
Table: PHARMA
7
(a) Anmol wants to change the name of the attribute UNITS to QUANTITY in the table
PHARMA. Which of the following commands will he use for the purpose?
UPDATE
DROPTABLE
CREATETABLE
ALTERTABLE
(b)Now Anmol wants to increase the PRICE of all medicines by 5. Which of the following
commands will he use for the purpose?
UPDATESET
INCREASEBY
ALTERTABLE
INSERTINTO
Q35.
(a) Write one difference between CSV and text files. 5
Write a program in Python that defines and calls the following user
defined functions:
(i) COURIER ADD(): It takes the values from the user and adds the details to a csv file 'courier.csv'.
Each record consists of a list with field elements as cid, s_name, Source, destination to store
CourierID, Sender name, Source and destination address respectively.
(ii) COURIER SEARCH (): Takes the destination as the input and displays all the courier records going
to that destination.
OR
(b) Why it is important to close a file before exiting?
Write a program in Python that defines and calls the following user defined functions:
(i) Add_Book(): Takes the details of the books and adds them to a csv file ‘Book.csv’. Each record
consists of a list with field elements as book_ID, B_ name and pub to store book ID, book name and
publisher respectively.
(ii) Search_Book(): Takes publisher name as input and counts and displays number of books published
by them.