Class 12-Special Computer Science PB-1
Class 12-Special Computer Science PB-1
2022-23
General Instructions:
SECTION A
1 State True or False
“Identifier can start with an underscore “
7. The command can be used to makes changes in the rows of a table in SQL.
a.Alter b.Modify c.Insert d.Update
8. Suggest the suitable command to remove the pre-existing database named Clients.
(a) delete database Clients (b) drop Clients (c) drop database Clients (d) Alter table drop Clients
9.Which of the following statement(s) would give an error after executing the following code?
STRING=”WELCOME “ #Statement 1
NOTE=” ” #Statement 2
for S in range[0,8]: #Statement 3
print (S) #Statement 4
15.Which of the following clauses in SQL is most appropriate to use to select matching tuples in a
specific range of values ?
(a) IN (b) LIKE (c) BETWEEN (d) IS
16 returns the number of rows affected by the last execute method for the same cur
object a.count() b.rowcount() c.countrow() d.countall()
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):- The Global variable can be accessed inside or outside of the function
Reasoning (R):- A variable declared outside of the function or in global scope is known as global variable.
18. Assertion (A): Function blocks begin with the keyword def followed by the function name and parentheses (
( ) ).
Reason (R): In Function, a return statement with no arguments gives an error message
SECTION B
19. Gurjot has written a code to input a number and find a new number Reverse from Number with each of the
digits of Number in reversed order and display the content of Reverse on screen. His code is having errors. Re-
write the correct code and underline the corrections made.
Def REVERSAR(Number):
S=0
while Number<0:
S=S*10+Number/10
Number=Number//10
print(S)
OR
How are tags used in XML different from tags in HTML? Write 2 points
22. Differentiate between the Primary key and Alternate key of a table with the help of an example
23 (a) Write the full form of the following abbreviations:
(i) POP (ii) VoIP
(b) What is web hosting?
24. Predict the output of the Python code given below:
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [8,20,1,4,3]
for CNT in range (4,0,-
1): A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),’*’, end=’ ‘)
OR
Predict the output of the Python code given below:
tuple1 = (6, 8, 32, 66, 3 ,6)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
25 While using SQL pattern matching, what is the difference between ‘_’(underscore) and ‘%’ wildcard sym-
bols?
OR
Categorize the following commands as DDL or DML:
DROP TABLE, INSERT, ALTER, DELETE
SECTION C
27 Write a method in python to read lines from a text file INDIA.TXT, to find and display the occurrence of
the word “India”.
28(a). Consider the following tables EMPLOYEES and EMPSALARY. Write SQL outputs for SQL queries
(i) to (iv).
EMPLOYEES
EMPID FIRSTNAME LASTNAME ADDRESS CITY
010 George Smith 83 First Street Howard
105 Mary Jones 842 Vine Ave. Losantiville
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends Street New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Henry Williams 12 Moore Street Boston
400 Rachel Lee 121 Harrison St. New York
441 Peter Thompson 11 Red Road Paris
EMPSALARY
EMPID SALARY BENEFITS DESIGNATION
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 Salesman
29 Write definition of a Method AFIND(CITIES) to display all the city names from a list of CITIES, which are
starting with alphabet A.
For example:
If the list CITIES contains
[“AHMEDABAD”,”CHENNAI”,”NEW DELHI”,”AMRITSAR”,”AGRA”]
30. Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The
function returns the value deleted from the stack.
OR
Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers
divisible by 5 into a stack implemented by using a list. Display the stack if it has at least one element,
otherwise display appropriate error message.
SECTION D
31. BeHappy Corporation has set up its new centre at Noida, Uttar Pradesh for its office and web-based
activi- ties. It has 4 blocks of buildings.
A to B 40 m
B to C 120m
C to D 100m
A to D 170m
B to D 150m
A to C 70m
(a) Suggest and draw the cable layout to efficiently connect various blocks of buildings within the Noida
centre for connecting the digital devices.
(b) Suggest the placement of the following device with justification
i. Repeater ii. Hub/Switch
(c) Which kind of network (PAN/LAN/WAN) will be formed if the Noida office is connected to its head
office in Mumbai?
(d) Which fast and very effective wireless transmission medium should preferably be used to connect the
head office at Mumbai with the centre at Noida
(i) To create a MySQL connection named db for localhost, with username = “teacher” and password =
“my- class”
Str1=”EXAM2018”
Str2=””
I=0
while I<len(Str1):
if Str1[I]>=”A” and Str1[I]<=”M”:
Str2=Str2+Str1[I+1]
elif Str1[I]>=”0” and Str1[I]<=”9”:
Str2=Str2+ (Str1[I-1])
else:
Str2=Str2+”*”
I=I+1
print (Str2)
(b) A resultset is extracted from the database using the cursor object (that has been already created) by
giving the following statement.
Mydata=cursor.fetchone()
SECTION E
Table: MOVIEDETAILS
Table: SCHEDULE
SLOTID MOVIEID TIMESLOT
S001 M010 10 AM to 12 PM
S002 M020 2 PM to 5 PM
S003 M010 6 PM to 8 PM
S004 M011 9 PM to 11 PM
Which field will be considered as the foreign key if the tables MOVIEDETAILS and SCHEDULE are related in
a database?
35.Amritya Seth is a programmer, who has recently been given a task to write a python code to perform the
fol- lowing binary file operations with the help of two user defined functions/modules:
a. AddStudents() to create a binary file called STUDENT.DAT containing student information – roll
number, name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who have a percentage greater than 75.
In case there is no student having percentage > 75 the function displays an appropriate message. The
function should also display the average percent. He has succeeded in writing partial code and has missed out
certain statements, so he has left certain queries in comment lines.
You as an expert of Python have to provide the missing statements and other related queries based on the fol-
lowing code of Amritya.
Answer any four questions (out of five) from the below mentioned questions.
import pickle
def AddStudents():
#1 statement to open the binary file to write data
while True:
Rno = int(input(“Rno :”))
Name = input(“Name : “)
Percent = float(input(“Percent :”))
L = [Rno, Name, Percent]
#2 statement to write the list L into the file
Choice = input(“enter more (y/n): “)
if Choice in “nN”:
break
F.close()
def GetStudents():
Total=0
Countrec=0
Countabove75=0
with open(“STUDENT.DAT”,”rb”) as F:
while True:
try:
#3 statement to read from the
file Countrec+=1
Total+=R[2]
if R[2] > 75:
print(R[1], “ has percent = “,R[2])
Countabove75+=1
except:
break
if Countabove75==0:
print(“There is no student who has percentage more than 75”)
average=Total/Countrec
print(“average percent of class = “,average)
AddStudents()
GetStudents()
i. Which of the following commands is used to open the file “STUDENT.DAT” for writing only in binary
for- mat? (marked as #1 in the Python code)
a. F= open(“STUDENT.DAT”,’wb’) b. F= open(“STUDENT.DAT”,’w’)
c. F= open(“STUDENT.DAT”,’wb+’) d. F= open(“STUDENT.DAT”,’w+’)
ii. Which of the following commands is used to write the list L into the binary file, STUDENT.DAT? (marked
as #2 in the Python code)
a. pickle.write(L,f) b. pickle.write(f, L) c. pickle.dump(L,F) d. f=pickle.dump(L)
iii. Which of the following commands is used to read each record from the binary file
STUDENT.DAT? (marked as #3 in the Python code)
a. R = pickle.load(F) b. pickle.read(r,f) c. r= pickle.read(f) d. pickle.load(r,f)
iv. Which of the following statement(s) are correct regarding the file access modes?
a. ‘r+’ opens a file for both reading and writing. File object points to its beginning.
b. ‘w+’ opens a file for both writing and reading. Adds at the end of the existing file if it exists and creates a new
one if it does not exist.
c. ‘wb’ opens a file for reading and writing in binary format. Overwrites the file if it exists and creates a new one
if it does not exist.
d. ‘a’ opens a file for appending. The file pointer is at the start of the file if the file exists.
v. Which of the following statements correctly explain the function of seek() method?
a. tells the current position within the file.
b. determines if you can move the file position or not.
c. indicates that the next read or write occurs from that position in a file.
d. moves the current file position to a given specified position.