Practical SampleQuest
Practical SampleQuest
a list of strings in the parameter N and pushes all strings which have no
vowels present, into a stack named NoVowel.
• Another function which will pop each word from the stack NoVowel and
display the popped word. When the stack is empty display the message
"EmptyStack".
def PushNV(N):
for i in N:
V=False
for J in i:
if J.upper() in 'AEIOU':
V=True
if V== False:
NoVowel.append(i)
def POP():
while True:
if NoVowel!=[]:
print(NoVowel.pop(),end=" ")
else:
print("Empty Stack")
break
#main
L=['PLY', 'GLOBE', 'MYTH', 'GLASS', 'CYST']
NoVowel=[ ]
PushNV(L)
print(NoVowel)
POP()
def PUSH(Arr):
for i in Arr:
if i%5==0:
ALL5.append(i)
def POP( ):
while True:
if ALL5 != []:
print(ALL5.pop(), end=” “)
else:
print(“Empty Stack)
break
#main
ALL5= []
Arr=[12,25,160,98,100]
PUSH(Arr)
POP( )
a) Write a function ETCount() in Python, which should read each character
of a text file “TESTFILE.TXT” and then count and display the count of
occurrence of alphabets E and T individually (including small cases ‘e’
and ‘t’ too).
def ETCount():
f=open("TESTFILE.TXT ",'r')
str=f.read()
s=0
c=0
for I in str :
if I in ‘Ee’:
s+=1
elif I in 'Tt':
c+=1
print("E or e : ", s )
print("T or t : “,c)
f.close()
b) Write a method NoVOWwords() in Python to read from text file
‘TESTFILE.TXT’ and display the words which are not starting with any
vowel.
def ETCount():
f=open("TESTFILE.TXT ",'r')
str = f.read()
L = str. split()
for i in L:
if i[0] not in ‘aeiouAEIOU’:
print(i, end=” “ )
f.close()
Q2. Write the queries (a) to (d) based on the table “Product”, showing details
of products being sold in a grocery shop.
Table: Product
Pcode Pname Uprice Manufacturer
P01 Washing Powder 120 Surf
P02 Toothpaste 54 Colgate
P03 Soap 25 Lux
P04 Toothpaste 65 Pepsodent
P05 Soap 38 Dove
P06 Shampoo 245 Dove
a) To display all the records of table product in ascending order by Pname.
Select * from Product order by Pname;
b) To display Pname and Manufacturer whose manufacturer is “Dove”
Select Pname, Manufacturer where Manufacturer= “Dove”;
c) To display all records from table product whose Uprice is more than 50.
Select * from Product where Uprice <50;
d) To delete all those records from the table product whose Pname starts with
“S”
delete from Product where Pname like “S%”;
Q2. Write the queries (a) to (d) based on the table “Customer”.
Table: Customer
CUSTID NAME PRICE QTY
101 ROHAN 70000 20
102 DEEPAK 50000 10
103 MOHAN 30000 5
104 SAHIL 35000 3
105 NEHA 25000 7
a) To display all the records of customer whose QTY is between 10 to 20.
Select * from Customer where QTY between (10 and 20);
b) To display name and price of those customer chose price is less than 40000
Select Name, Price from Customer where price<40000;
c) To display those customer records whose name last letter is “N”.
Select * from Customer where Name like ‘%N’;
d) To modify the QTY by adding +5 of those whose custid is 102 or 104
Update Customer set Qty= Qty+5 where custid in (102, 104);