XII 1st PRE BOARD QP Withsolution 2023

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

Time 3.00 Hrs. CLASS XII PYTHON (083) FIRST PRE-BOARD EXAM (2022-2023) M.M.

70
General Instructions:
(i) All questions are compulsory.
(ii) This Paper contains five sections, Section A to E.
(iii) Section A has 18 questions carrying 01 marks each.
(iv) Section B has 07 questions carrying 02 marks each.
(v) Section B has 07 questions carrying 02 marks each.
(vi) Section C has 05 questions carrying 03 marks each.
(vii) Section D has 03 questions carrying 05 marks each.
(viii) Section E has 02 questions carrying 04 marks each.
(viii) All Questions are to be answered using Python Language only.
SECTION - A
1. State True or False
“Variable declaration is implicit in Python.”
2. Which of the following is an invalid data type in Python?
(a) Set (b) None (c)Integer (d)Real
3. Given the following dictionaries:-
dict_exam={“Exam”:”AISSCE”, “Year”:2023}
dict_result={“Total”:500, “Pass_Marks”:165}
Which statement will merge the contents of both dictionaries?
i) dict_exam.update(dict_result)
ii) dict_exam + dict_result
iii) dict_exam.add(dict_result)
iv) dict_exam.merge(dict_result)
4. Consider the given expression: not True and False or True
Which of the following will be correct output if the given expression is evaluated :
(a)True (b)False (c)NONE (d)NULL

5. Select the correct output of the code:


a = “Year 2022 at All the best”
a = a.split(‘2’)
b = a[0] + “. ” + a[1] + “. ” + a[3]
print (b)
i) Year . 0. at All the best
ii) Year 0. at All the best
iii) Year . 022. at All the best
iv) Year . 0. at all the best
6. Which of the following mode in file opening statement results or generates an error if the file
does not exist? (a) a+ (b) r+ (c) w+ (d) None of the above
7. Fill in the blank:
______ command is used to remove primary key from a table in SQL.
(a)update (b)remove (c) alter (d)drop
8. Which of the following commands will delete the table from MYSQL database?
(a) DELETE TABLE (b) DROP TABLE (c) REMOVE TABLE (d) ALTER TABLE
9. Which of the following statement(s) would give an error after executing the following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3 (b) Statement 4 (c) Statement 5 (d) Statement 4 & 5
[ PAGE - 1 ]

10. Fill in the blank:


………is a non-key attribute, whose values are derived from the primary key of some other table.
i) Primary Key ii) Foreign Key iii) Candidate Key iv) Alternate Key
11. The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
12. Fill in the Blank:
The SELECT statement when combined with………. clause returns records without repetition.
i) DESCRIBE ii) UNIQUE iii) DISTINCT iv) NULL
13. Fill in the blank:
……is a communication methodology designed to deliver both voice and multimedia
communications over Internet protocol.
(a) VoIP (b) SMTP (c) PPP (d)HTTP
14. Suppose list1 is [1, 3, 2], What is list1 * 2 ?
a) [2, 6, 4]. b) [1, 3, 2, 1, 3]. c) [1, 3, 2, 1, 3, 2] . d) [1, 3, 2, 3, 2, 1]
15. To write data into CSV from python console, which of the following function iscorrect?
a) csv.write(file) b) csv.writer(file) c) csv.write(file) d) csv.writerow()
16. To establish a connection between Python and SQL databases, connect() is used. Which of
the following arguments may not necessarily be given while calling connect() ?
(a) host (b) database (c) user (d) password
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
17. Assertion (A):- If the arguments in a function call statement match the number and order of
arguments as defined in the function definition, such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains default argument(s) followed by
positional argument(s).
18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks like a
text file. Reason (R): The information is organized with one record on each line and each field is
separated by comma. SECTION – B
19. Evaluate the following expressions:
a) 6+7*4+2**3//5-8
b) 8<5 or not 19<=20 and 11<4
20. Write down the full form of : a) POP b) TCP/IP c) WWW d) HTTPS
21. Differentiate between Candidate Key & Primary Key in the context Relational Database Mode.
22. What will be the output of the following code?
a=[1, 2, 3, 4]
s=0
for a[-1] in a:
print(a[-1])
s+=a[-1]
print(‘sum=’, s)
23. Difference between ALTER & UPDATE commands.
24. Smridh has recently changed his school so he is not aware of the people, but someone is posting
negative , demeaning comments on his social media profile. He is also getting repeated mails from
unknown people. Every time he goes online, he finds someone chasing him online.
i. Smridh is a victim of …………
ii.The act of fraudulently acquiring someone’s personal and private information, such as
online account names, login information and passwords is called as ……………
25. In the table Loan below
(a) Identify the candidate key(s) from the table Garment.
(b) What is the cardinality and degree of the table?
SECTION – C
26. Vedika has created a dictionary containing names and marks as key-value pairs of 5
students. Write a program, with separate user-defined functions to perform the following
operations:
Push() to push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70. Pop() & display() the content of the stack.
The dictionary should be as follows:
d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
Then the stack will be: Umesh Vishal Ishika
27. A department is considering to maintain their worker data using SQL to store the data. As a
database administer, Karan has decided that :
Name of the database - Department
Name of the table - WORKER
The attributes of WORKER are as follows:
WORKER_ID - character of size 3
FIRST_NAME – character of size 10
LAST_NAME– character of size 10
SALARY - numeric
JOINING_DATE – Date
DEPARTMENT – character of size 10
I) Identify the attribute best suitable to be declared as a primary key.
ii) Karan wants to increase the size of the FIRST_NAME column from 10 to 20
characters. Write an appropriate query to change the size.
III) Karan wants to remove all the data from table WORKER from the database Department.
Write an appropriate query to remove the data as said above.
28. Ashok Kumar of class 12 is writing a program to create a CSV file “cust.csv” with custid,
custname and mobile no and search custname and delete the record. He has written the
following code. As a programmer, help him to successfully execute the given task.
import ______ # LINE1
record = list()
custname= input("Please enter a customer name to delete:")
with open('cust.csv', 'r') as f:
data = csv _________ (f) # LINE2
for row in data:
record.append(row)
for field in row:
if field == custname:
record._______ (row) #LINE3
with open('cust.csv', 'w') as f:
writer = csv.writer(f)
writer.writerows(record)
a) Name the module he should import in Line 1.
b) Write a code to read the fields (column heading) once from fields list inLine2.
c) Write a code to delete the row from row list in Line3.
29. Write SQL commands for(a) to (b) and write the outputs for (C) on the basis of table GRADUATE

a) List the names of those students who obtained DIV 1 sorted by NAME .
b) Display a report, listing NAME , STIPEND , SUBJCT and amount of stipend
received in a year assuming that the STIPEND is paid every month.
c) Give the output of the following SQL statements based on table GRADUATE :
(i) Select MIN(AVERAGE ) from GRADUATE where SUBJECT= “PHYSICS”;
(ii)Select SUM(STIPEND) from GRADUATE where DIV=1;
30. A) Write a function countmy() in Python to read the text file "DATA.TXT" and count the
number of times "my" occurs in the file. For example, if the file "DATA.TXT" contains
"This is my website. I have displayed my preferences in the CHOICE section." - the
countmy() function should display the output as: "my occurs 2 times"
Or
Write a method/function DISPLAYWORDS() in python to read lines from a text file
STORY.TXT, and display those words, which are less than 4 characters
SECTION – D
31. Young Minds Ltd. is an educational organization. It is planning to setup its India campus at
Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN,
ENGINEERING, BUSINESS and MEDIA. You as a network expert have to suggest the best
network related solutions for their problems raised in (i) to (v), keeping in mind the
distances between the buildings and other given parameters.

Shortest distances between various buildings :


ADMIN to ENGINEERING 55 m

ADMIN to BUSINESS 90 m
ADMIN to MEDIA 50 m
ENGINEERING to BUSINESS 55 m
ENGINEERING to MEDIA 50 m
BUSINESS to MEDIA 45 m
DELHI Head Office to CHENNAI Campus 2175 km

Number of Computers installed at various buildings are as follows :


ADMIN 110
ENGINEERING 75
BUSINESS 40
MEDIA 12

DELHI Head Office 20


(i) Suggest the most appropriate location of the server inside the CHENNAIcampus (out of the 4
buildings), to get the best connectivity for maximum no. of computers. Justify your answer.
(ii) Suggest the topology and draw the cable layout to efficiently connect various buildings
within the CHENNAI campus.
(iii) Which hardware device will you suggest to be procured by the companyto minimize the
transmission loss?
(iv) Which will be the most suitable wireless communication medium to connect Chennai
campus with its Delhi head office?
(v) Which of the following will you suggest to establish the online face-to- face
communication between the people in the Admin Office of CHENNAI Campus and
DELHI Head Office?
a) Cable TV b) Email c) Video Conferencing d) Text Chat
32. Write the SQL commands for the following questions (i) to (v) based on the relations Car
and Customer given below: Car
Ccode Cname Make Colour Capacity Charges
201 Triber Renault Yellow 7 1000
203 Altroz Tata Black 5 1500
208 Innova Toyota Silver 8 3000
209 Harrier Tata White 6 2000
212 Duster Renault Red 6 2500
217 Ertiga Suzuki Grey 7 2300
Customer
Custcode Custname Ccode
101 Gopinath 201
102 Ashok 203
103 Harshini 201
104 Vishnu 212
To display the Names and Charges of all the Silver coloured cars.
(i) To display the non duplicate car codes in the customer table.
(ii) To display the Minimum and Maximum car charges.
iv) To give a discount of 10% in the car charges for existing customers (who are in the
customer table).
(iii) To display Name and Make of cars whose charges is in the range 2000
to 3000 (both inclusive).
33. A binary file “vehicle.dat” has structure [RegNo, Type, Make, Year].
a) Write a user defined function AddVahan() to input data for a vehicle and add to “vehicle.dat”
file.
b) Write a function CountVahan(Type) in Python which accepts the Type of the vehicle
as the parameter and count and return the number of vehicles of the given Type.
OR
A binary file “player.dat” has structure (PlayerId, Name, Team, StrikeRate). Write a
function ShowPlayer() in Python that would read contents of the file and display the
details of those players whose Team is “India” and StrikeRate is above 50. Also display
the total number of such players.
SECTION – E
34. A Book store Current Books is planning to store their book details in a database using
SQL. As a database administrator, Poorvekka has decided that:
(a) Name of the database - CB 34.
(b) Name of the table - Collections
(c) The attributes of Collections are as follows:
BookNo - Numeric
BookName – Character of size 25
Price – Numeric
Quantity – Numeric
Table : Collections
BookNo BookName Price Quantity
1647 The Lowland 399 75
5241 The Inheritance Of Loss 555 44
3546 The Guide 641 60
4541 Untouchable 529 53

5025 Train to Pakistan 643 73


6783 Godan 341 97
7614 The God Of Small Things 555 48

(d) Identify the attribute best suitable to be declared as a primary key,


(e) Write the degree and cardinality of the table Collections.
(f) Write SQL command to increment the quantity by 20 whereverquantity is below 50.
(d) Poorvekka wants to remove the entire data from table Collections. Which
command will she use from the following:
• DELETE FROM Collections;
• DELETE Collections;
• DROP DATABASE CB;
• DELETE * FROM Collections;
35. Atul Prakash of Class 12 is writing a program to create a CSV file “students.csv” which will
contain student name and admission number for some entries. He has written the
following code. As a programmer, help him to successfully execute the given task.

import # Line 1

def Addstudents(Name, Admno): # to write / add data into the CSV


f=open('students.csv', ' ') # Line2
writerObj=csv.writer(f)
writerObj.writerow([Name,Admno])
f.close()

#csv file reading code


def Retrievestudents(): # to read data from CSV
with open(' students.csv','r') as fobj:
readerObj=csv.___________(fobj) # Line3
for row in readerObj:
print (row[0],row[1])
fobj.close() # Line4

AddStudents(“Raghava”, “2541”)
AddStudents (“Pooja”,”3411”)
AddStudents(“Krutika”,”2218”)
Retrievestudents () #Line 5

a) Name the module to be imported in Line 1.


b) Which mode Atul should open the file to add data.
c) Fill in the blank in Line 3 to read data from a csv file.
d) Is Line 4 mandatory? Justify your answer.

----------******----------
Answer to the Above Question Paper
SECTION A
1. True
2. d) real
3. i) dict_exam.update(dict_result)
4. a) True
5. i) Year.0.at All the best
6. b) r+
7. c) alter
8. b) DROP TABLE
9. b) statement 4
10. ii) Foreign key
11. (a) file_object.seek(offset [, reference_point])
12. iii) DISTINCT
13. a) VoIP
14. c) [1,3,2,1,3,2]
15. b) csv.writer(file)
16. b) database
17. c)
18. a)

Section B

19 a) 27 b) False 2
20 a) Post Office Protocol b)Transmission Control 2
Protocol/InternetProtocol c) World Wide Web
d) Hypertext Transfer Protocol Secure
21 Candidate Key: The columns which can serve as primary key of a 2
tableis known as candidate keys. There can be multiple candidate
for a relation.
Primary Key: Primary key is a field name which identifies rows
uniquely. There can be only one primary key for a relation.
22 1 2
2
3
3
Sum=9
23 ALTER Command is used to add, delete, modify the attributes of the 2
relations (tables) in the database. UPDATE Command is used to
updateexisting records in a database.
24 i)Cyber stalking ii)Phishing 2
25 a) GCODE, GNAME, b) Degree=5 & Cardinality=6 2
26 def 3
push(stk,item):
stk.append(item
)
def
Pop(stk):
if stk==[]:
return
Noneelse:
return
stk.pop()stk=[]
d={"Ramesh":58, "Umesh":78, "Vishal":90, "Khushi":60,
"Ishika":95}for i in d:
if d[i]>70:
push(stk,i
)
while
True: if
stk!=[]:
print(Pop(stk),end="
)else:
break
I) WORKER_ID
27 3
II) alter table worker modify FIRST_NAME varchar(20);
lll)DELETE FROM WORKER;
28. a) csv 3
.b) reader
.c) remove
29 A. List the names of those students who obtained DIV 1 sorted 2+1
byNAME .
Ans.: SELECT name FROM graduate WHERE div=1 ORDER BY
name; (b )Display a report, listing NAME , STIPEND , SUBJCT and
amount ofstipend received in a year
assuming that the STIPEND is paid every month.
Ans.: SELECT name, stipend, subject, stipend *12 FROM graduate;
(C) Give the output of the following SQL statements based on
tableGRADUATE :
(i) Select MIN(AVERAGE ) from GRADUATE where
SUBJECT=”PHYSICS”;Ans. MIN(AVERAGE)

63
(ii) Select SUM(STIPEND) from GRADUATE where
DIV=1;Ans.: SUM(STIPEND)
1000

30 A) 3
def countmy ():
f = open("DATA.txt", "r")
count = 0
x = f.read()
word =
x.split()for i in
word :
if (i == "my") :
count = count + 1
print ("my occurs", count,
"times")

A. close()
Or

ii) )
def DISPLAYWORDS() :
file = open("story.txt",
"r")lst = file.readlines()
for i in lst :
word =
i.split()for j in
word :
if len( j ) < 4
:print( j )
file.close()
print("Word with length smaller than 3 :-
\n")DISPLAYWORDS()
SECTION -D
(i) Most suitable place to install the server is ADMIN, as this building
31 hasmaximum number of computers. 5
(ii) Topology: STAR
Cable layout:

(iii) Repeater
(iv) Satellite Link
(v) (c) Video Conferencing
32 (i) Select Cname, Charges from Car where Colour=’silver’; 5
(ii) Select distinct Ccode from customer;
(iii) Select min(Charges), max(Charges) from Car;
(iv) Update Car set Charges=Charges - Charges*0.1 from Car R,
Customer Cwhere R.Ccode=C.Ccode;
(v) Select Cname, Make from Car where Charges between 2000 and 3000;

33 import pickle 5
def
AddVahan():
f1= open(“vehicle.dat”, “ab”)
RegNo = input(“Enter the vehicle registration number: “)
Type = input(“Enter the vehicle type: “)
Make = input(“Enter the manufacturer name: “)
Year = int(input(“Enter the year of manufacturing:
"))rec = [RegNo, Type, Make, Year]
pickle.dump(rec,
f1)f1.close()
def CountVahan(Type):
f1 = open(“vehicle.dat”,
“rb”)count = 0
try:
while True:
rec =
pickle.load(f1)if
Type == rec[1]:
count = count +
1except:
f1.close()
return
count
OR
import pickle
def ShowPlayer():
f1 = open(“player.dat”,
“rb”)count = 0
try:
while True:
rec= pickle.load(f1)
if rec[3] >50 and rec[2] == “India”:
print(rec [0], rec [1], rec [2], rec [3],sep=”\t”)
count
+=1except:
f1.close()
print(“Number of Indian players with strike rate more than 50=”, count)
SECTION E
34 (a) BookNo 4
(b) Degree=4 Cardinality =7
(c) UPDATE collections SET quantity = quantity + 20 WHERE quantity < 50;
(d) DELETE FROM Collections;
35 (a) Line 1 :import csv 4
(b) Line 2 :f=open('students.csv','a')
(c) Line 3 :readerObj=csv.reader(fobj)
(d) Line 4: Not mandatory, as we have opened the file using “with”
operator, itcloses automatically.

You might also like