Coimbatore Sahodaya Set A Key
Coimbatore Sahodaya Set A Key
Coimbatore Sahodaya Set A Key
Table: CONSIGNEE
CneeID CnorID CneeName CneeAddress CneeCity
MU05 ND01 Rahul Kishore 5, Park Avenue Mumbai
ND08 ND02 P Dhinga 16/J, Moore Enclave New Delhi
KO19 MU15 A P Roy 2A, Central Avenue Kolkata
MU32 ND02 S Mittal P 245, AB Colony Mumbai
ND48 MU50 B P Jain 13, Block D, A Vihar New Delhi
Give output for the following SQL queries:
(i) SELECT A.CnorName, B.CneeName
FROM Consignor A, Consignee B
WHERE A.CnorID=B.CnorID AND B.CneeCity=’Mumbai’;
(ii) SELECT CneeName, CneeAddress
FROM Consignee
WHERE CneeCity NOT IN(‘Mumbai’, ‘Kolkata’);
(iii) SELECT DISTINCT CneeCity FROM Consignee;
Ans. (i) R Singhal Rahul Kishore
Amit Kumar S Mittal
(ii) P Dhingra 16/j, Moore Enclave
BP Jain 13, Block D, A Vihar
(iii) Mumbai
New Delhi
Kolkata
27 Write a function Show_words( ) in python to read the content of a text file 3
‘NOTES.TXT” and display the entire content in capital letters. Example if
the file contains:
“This is a test file”
Then the function should display the output as:
THIS IS A TEST FILE
Ans. def Show_words( ):
file=open(‘Notes.txt’,’r’)
Lines=file.readlines( )
for L in Lines:
print(L.upper())
file.close( )
(OR)
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”
Ans. 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”)
f.close( )
countmy( )
28 Consider the following tables WORKER and PAYLEVEL and answer the 3
following parts of this question:
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhe Supervisor P001 13-09- 23-08-
Shyam 2004 1981
12 Chander Operator P003 22-02- 12-07-
Nath 2010 1987
13 Fizza Operator P003 14-06- 14-10-
2009 1983
15 Ameen Mechanic P002 19-12- 13-03-
Ahmed 2005 1983
18 Sanya Clerk P002 19-12- 09-06-
2005 1983
Table: PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
Give the output for the following SQL queries:
(i) SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY
PLEVEL;
(ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W.PLEVEL=P.PLEVEL AND W.CODE<13;
Ans. (i) 1 P001 (ii) 12-Jul-1987 13-Sep-2004
2 P003
3 P002
(iii) Name Pay
Radhe shyam 26000
Chander Nath 12000
29 Write a function stats( ) that accepts a filename and reports the file’s longest 3
line.
Ans. def stats(filename):
longest=” “
for line in file(filename):
if len(line)> len(longest)
longest=line
print(“Longest line’s length=” , len(longest))
print (longest)
30 Write Addnew(Book) and Remove(Book) functions in python to add a new 3
book and remove a book from a List of books, considering them to act as
PUSH and POP operations of the data structure Stack.
Ans. Book=[ ]
def Addnew(s):
name=input(“Enter book name:”)
Book.append(name)
def Remove(self):
if( Book==[ ]):
print(“Stack Empty. Underflow”)
else:
print(“Deleted book is :”, Book.pop())
(OR)
Write a function called letter_freq(my_list) that takes one parameter, a list
of strings(mylist) and returns a dictionary where the keys are the letters
from mylist and the values are the number of times that letter appears in the
mylist, e.g.,if the passed list is as:
wlist=list(“aaaaabbbbcccdde”)
then it should return a dictionary as{‘a’:5,’b’:4,’c’:3,’d’:2,’e’:1}
Ans. def letter_freq(mylist):
d={ }
for i in mylist:
if i not in d:
d[i] =mylist.count(i)
return d
wlist=list(‘aaaaabbbbcccdde”)
R=letter_freq(wlist)
print(R)
S.NO SECTION-D MARKS
31 Learn Together is an educational NGO. It is setting up its new campus at 5
Jabalpur for its web-based activities. The campus has four compounds as
shown in the diagram below: