Board Question
Board Question
Rollno - numeric
Name – character of size 20
Class - character of size 20
Fees – Numeric
Qtr – Numeric
Answer any four from the following questions:
(i) Identify the attribute best suitable to be declared as a primary key
(ii) Write the degree of the table.
(iii) Insert the following data into the attributes Rollno, Name, Class, Fees and Qtr in fees table.
(iv) Aman want to remove the table Fees table from the database School.
Which command will he use from the following:
a) DELETE FROM Fees;
b) DROP TABLE Fees;
c)DROP DATABASE Fees;
d) DELETE Fees FROM Fees;
(v) Now Aman wants to display the structure of the table Fees, i.e, name of the attributes and their
respective data types that he has used in the table. Write the query to display the same.
Ans i)Primary Key – Rollno
ii)Degree of table= 5
iii)Insert into fees values(101,’Aman’,’XII’,5000);
iv)DELETE FROM Fees
v)Describe Fees
23 Anis of class 12 is writing a program to create a CSV file “mydata.csv” which will contain user name and 1x4
password for some entries. He has written the following code. As a programmer, help him to successfully =4
execute the given task.
OR
Web Page is a document or a page where there is information. We can see those pages in the browser.
Web Page is a single page with information. It can be in any form like texts, images or videos.
Whereas the Website is a collection of webpages. The website has its own domain name which is unique
throughout the world. Anything can be stored on a website like photos, videos, texts etc .
Popular example of online shopping : Amazon,Flipcart etc
26 Expand the following terms: 2
a. HTTP b. FLOSS c. PAN d. IRC
Ans HTTP – Hyper Text Transfer Protocol
FLOSS- Free Libre Open Source Software
PAN- Personal Area Network
IRC- Internet Relay Chat
27 Differentiate between call by value and call by reference with a suitable example for each. 2
OR
Explain the use of return key word used in a function with the help of a suitable example.
Ans In the event that you pass arguments like whole numbers, strings or tuples to a function, the passing is
like call-by-value because you can not change the value of the immutable objects being passed to the
function. Whereas passing mutable objects can be considered as call by reference because when their
values are changed inside the function, then it will also be reflected outside the function.
OR
The return statement is used to return a value of function to its calling program.
Example:
def mysum(a,b):
return a+b
print(mysum(10,20))
Output: 30
28 Rewrite the following code in Python after removing all syntax error(s). Underline each correction done 2
in the code.
p=30
for c in range(0,p)
If c%4==0:
print (c*4)
Elseif c%5==0:
print (c+3)
else
print(c+10)
Ans p=30
for c in range(0,p):
if c%4==0:
print (c*4)
elif c%5==0:
print (c+3)
else:
print(c+10)
29 What possible outputs(s) are expected to be displayed on screen at the time of execution of the program 2
from the following code? Also specify the maximum values that can be assigned to each of the variables
Lower and Upper.
import random
AR=[20,30,40,50,60,70];
Lower =random.randint(1,4)
Upper =random.randint(2,5)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
30 What do you understand by Foreign Key in a table? Give a suitable example of Foreign Key from a table 2
containing some meaningful data.
Ans A Foreign Key creates a link between tables. It references the primary key in another table and links it.
For example, the DeptID in the Employee table is a foreign key –
31 Differentiate between fetchone() and fetchall() methods with suitable examples for each. 2
Ans fetchall() fetches all the rows of a query result. An empty list is returned if there is no record to fetch the
cursor. fetchone() method returns one row or a single record at a time. It will return None if no more
rows / records are available. Any example.
32 Categorize the following as DML and DDL Commands: 2
SELECT, INSERT, CREATE, UPDATE, ALTER, DELETE, DROP
Ans DDL – Create, Alter, Drop
DML- Select, Insert, Update, Delete
33 Find and write the output of the following Python code: 2
def Show(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Show('HappyBirthday')
Ans hAPPYbIRTHDAY
OR
Write a function AMCount() in Python, which should read each character of a text file STORY.TXT, should
count and display the occurrences of alphabets A and M (including small cases a and m too).
Example: If the file content is as follows:
Updated information As simplified by official websites.
OR
def AMCount():
f=open("story.txt","r")
A,M=0,0
r=f.read()
for x in r:
if x[0]=="A" or x[0]=="a" :
A=A+1
36 Consider the table TEACHER given below. Write commands in SQL for (i) to (iii) 3
TEACHER
ID Name Department Hiredate Category Gender Salary
1 Taniya SocialStudies 03/17/1994 TGT F 25000
2 Abhishek Art 02/12/1990 PRT M 20000
3 Sanjana English 05/16/1980 PGT F 30000
4 Vishwajeet English 10/16/1989 TGT M 25000
5 Aman Hindi 08/1/1990 PRT F 22000
6 Pritam Math 03/17/1980 PRT F 21000
7 RajKumar Science 09/2/1994 TGT M 27000
8 Sital Math 11/17/1980 TGT F 24500
i. To display all information about teachers of Female PGT Teachers.
ii. To list names, departments and date of hiring of all the teachers in descending order of date
of joining.
iii. To count the number of teachers and sum of their salary department wise.
Ans i) SELECT * FROM TEACHER WHERE CATEGORY= ‘PGT’ AND GENDER= ‘F’;
ii) SELECT NAME, DEPARTMENT, HIREDATE FROM TEACHER ORDER BY HIREDATE DESC;
iii) SELECT DEPARTMENT, COUNT(NAME), SUM(SALARY) FROM TEACHER GROUP BY DEPARTMENT;
37 Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push all numbers 3
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. OR 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.
Ans def PUSH(Arr,value):
s=[]
for x in range(0,len(Arr)):
if Arr[x]%5==0:
s.append(Arr[x])
if len(s)==0:
print("Empty Stack")
else:
print(s)
OR
def popStack(st) : # If stack is empty
if len(st)==0:
print("Underflow")
else:
L = len(st)
val=st[L-1]
print(val)
st.pop(L-1)
Part B Section III
38 Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as shown in the 5
diagram given below:
Acco Rese
unts arch
Store Pack
aging
Number of Computers
Accounts 25
Research Lab 100
Store 15
Packaging Unit 60
As a network expert, provide the best possible answer for the following queries:
i) Suggest a cable layout of connections between the buildings.
ii) Suggest the most suitable place (i.e. buildings) to house the server of this organization.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access to or from the network.
v) Which cable is best suited for above layout.
Ans i) Layout-
Account Researc
s h
Store Packagin
g
ii)The most suitable place/ building to house the server of this organization would be building
Research Lab, as this building contains the maximum number of computers.
(iii)
a) For layout1, since the cabling distance between Accounts to Store is quite large, so a repeater
would ideally be needed along their path to avoid loss of signals during the course of data flow in
this route. For layout2, since the cabling distance between Store to Research Lab is quite large,
so a repeater would ideally be placed.
b) In both the layouts, a Hub/Switch each would be needed in all the buildings to interconnect the
group of cables from the different computers in each building.
(iv) Firewall
(v) Twisted Pair cable / Ethernet cable
39 Write SQL commands for the queries (i) to (iii) and output for (iv) & (v) based 5
on a table COMPANY and CUSTOMER .
COMPANY
CID NAME CITY PRODUCTNAME
111 SONY DELHI TV
222 NOKIA MUMBAI MOBILE
333 ONIDA DELHI TV
444 SONY MUMBAI MOBILE
555 BLACKBERRY MADRAS MOBILE
666 DELL DELHI LAPTOP
CUSTOMER
CUSTID NAME PRICE QTY CID
101 Rohan Sharma 70000 20 222
102 Deepak Kumar 50000 10 666
103 Mohan Kumar 30000 5 111
104 Sahil Bansal 35000 3 333
105 Neha Soni 25000 7 444
106 Sonal Aggarwal 20000 5 333
107 Arjun Singh 50000 15 666
(i) To display those company name which are having price less than 30000.
(ii) To display the name of the companies in reverse alphabetical order.
(iii) To increase the price by 1000 for those customer whose name starts with ‘S’
(iv) SELECT PRODUCTNAME,CITY, PRICE FROM COMPANY,CUSTOMER
WHERE COMPANY.CID=CUSTOMER.CID AND PRODUCTNAME=”MOBILE”;
(v) SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
v) 12
OR
A binary file “STUDENT.DAT” has structure (admission_number, Name, Percentage). Write a function
countrec() in Python that would read contents of the file “STUDENT.DAT” and display the details of those
students whose percentage is above 75. Also display number of students scoring above 75%
Ans import pickle
def createFile():
fobj=open("Book.dat","ab")
BookNo=int(input("Book Number : "))
Book_name=input("Name :")
Author = input("Author:" )
Price = int(input("Price : "))
rec=[BookNo,Book_Name,Author,Price]
pickle.dump(rec,fobj)
fobj.close()
def CountRec(Author):
fobj=open("Book.dat","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if Author==rec[2]:
num = num + 1
except:
fobj.close()
return num
OR
import pickle
def CountRec():
fobj=open("STUDENT.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[2] > 75:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num