Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Roll No.: _______________________ Sub.

Code: 083

Please check that this question paper


contains 35 questions and 8 printed pages.

D.A.V. INSTITUTIONS, CHHATTISGARH


Practice Paper - 9 2023-24
Class: XII
Subject: Computer Science -Python (083)
Time: - 3 Hrs. Max. Marks.: 70
General Instructions:
➢ Question paper is containing 35 questions.
➢ The paper is divided into 5 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.
➢ In some question of Section B,C & E there will be internal choice.
➢ All programming questions are to be answered using Python Language only.
SECTION - A
Q1. Which of the following options isare not Python Keywords? 1
(a) False (b) Math (c) WHILE (d)break
Q2. Given the dictionary D={'Rno':1,'Name':'Suraj'}, write the output ofprint(D('Name')). 1
Q3. Identify the statement(s) from the following options which will raise Type Error
exception(s): 1
(a) print('5'*3) (b) print(5*3)
(c) print('5'+3) (d) print('5'+'3')
Q4. Identify the valid relational operator(s) in Python from the following: 1
(a) = (b) < (c) <> (d) not
Q5. For a string S declared as S='PYTHON',which of the following is incorrect? 1
(a) N=len(S) (b) N=len(S) (c) 'T'inS (d) S[0]='M'
Q6. Write a single line statement in Python to assign the values'BLUE','GREEN','RED'
to a tuple named Colours. 1
A List is declared as L=['ONE','TWO','THREE'] What will be the output of the statement?
1
Print(max(L))

Q7. Write the name of the built-infunctionmethod of the mathmodulewhich when executed

upon5.8 as parameter,would return the nearest smaller integer 5. 1


Q8. In context of Cyber Crimes and CyberThefts, the term IPR Rrefers to: 1
(a) Internet Protocol Rights (b) Inter Personnel Rights
(c) Intellectual Property Rights (d) Individual Property Rights
Q9. InSQL, write the name of the aggregate function which will display the cardinality of
a table. 1
Q10. Which of the following clauses in SQL is most appropriate to use to select matching tuples
in a specific range of values? 1
(a) IN (b) LIKE (c) Between (d) IS
Q11. Which of the following is nota valid DML command in SQL? 1
(a) INSERT (b) UPDATE (c) ALTER (d) DELETE
Q12. Which of the following wireless transmission media is best suited for MAN? 1
(a) Microwave (b) RadioLink (c) Infrared (d) Bluetooth
Q13. Which of the following is/are immutable object type(s) in Python? 1
(a) List (b) String (c) Tuple (d) Dictionary
Q14. What shall be the output for the execution of the following Python Code? 1
Cities=['Delhi','Mumbai']
Cities[0],Cities[1]=Cities[1],Cities[0]
print(Cities)
Q15. Which of the following statements correctly explains the term Firewall in context of
Computer Network Society? 1
(a) A device that protects the computer network from catching fire.
(b) Adevicesoftware that controls incoming and outgoing network traffic.
(c) Using abusive language on a social network site.
(d) Steal it as his/her own work.
Q16. Which of the following is not a valid python string operation? 1
(a) ‘Wlcome’ + ‘10’ (b) ‘Wlcome’ * 10
(C) ‘Wlcome’ * 10.0 (d) “10” + ‘Wlcome’
Q17 and 18 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
(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
Q17. Assertion (A): Opening a text file using ‘W’ mode deletes the existing

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

AC NO NAME GENDER BALANCE


C1 RISHABH M 15000
C2 AAKASH M 12500
C3 INDIRA F 9750
C4 TUSHAR M 14600

4
C5 ANKITA F 22000

AC NO TDATE AMOUNT TYPE


C1 2020-07-21 1000 DEBIT
C5 2019-12-31 1500 CREDIT
C3 2020-01-01 2000 CREDIT

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

TEACHERS UNIT STUDENT 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

MID MNAME PRICE UNITS EXPIRY


M1 PARACETAMOL 12 120 2022-12-25
M2 CETRIZINE 6 125 2022-10-12

M3 METFORMIN 14 150 2022-05-23


M4 VITAMINB-6 12 120 2022-07-01
M5 VITAMIND3 25 150 2022-06-30
M6 TELMISARTAN 22 115 2022-02-25

I)Write the degree and cardinality of the table PHARMA.


II)Identify the attribute best suitable to be declaired as a primary key
III) Anmol has received anew medicine to be added into his stock, but for which he does not
know the number of UNITS.So he decides to add the medicine without its value for UNITS. The rest
of the values are as follows :

MID MNAME PRICE EXPIRY


M7 SUCRALFATE 17 2022-03-20
Write the SQL command which Anmol should execute to perform the required task.

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.

You might also like