Prac-Final Code
Prac-Final Code
Write a python program to read a text file and display the number of vowels/consonants
/lower case/ upper case characters.
Contents=f.read()
Vowels=0
Consonants=0
Lower_case=0
Upper_case=0
space=0
for ch in Contents:
if ch in 'aeiouAEIOU':
Vowels-Vowels+1
if ch in 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ':
Consonants=Consonants+1
if ch.islower ():
Lower_case=Lower_case+1
if ch.isupper () :
Upper_case=Upper_case+1
if ch.isspace():
space=space+1
f.close()
Table : Cost
1 M 500 Raymond
1 L 580 Mattex
2 XL 620 Mattex
2 M 810 Yasin
2 L 940 Raymond
3 M 770 Yasin
3 L 830 Galin
4 S 150 Mattex
(a) Display the average price of all the Uniform of Raymond Company from table COST.
(b) Display details of all the Uniform in the Uniform table in descending order of Stock
date.
(c) Display max price and min price of each company.
(d) Display the company where the number of uniforms size is more than 2.
SET-A
);
);
SET-B
import pickle
def Create():
F=open ("Students.dat", 'ab')
pickle.dump (L,F)
F.close()
def Search():
found=0
try:
while True:
S=pickle.load(F)
if S[0]==no:
found=1
break
except:
F.close()
if found==0:
#Main Program
def main():
while True:
print("3. Exit")
if choice == '1':
Create()
Search ()
break
else:
main()
Table : Student
(a) Write a Query to display the name of the students whose name is ends with 'N'.
SET-B
FROM Student
SET-C
Write a Python program Create a CSV file to store Empno, Name, Salary and search any
Empno and display Name, Salary and if not found display appropriate message.
import csv
def Create():
file_path = r"D:\Users\User\Desktop\carton.txt"
W = csv.writer(F)
opt = 'y'
W.writerow(L)
def Search():
file_path = r"D:\Users\User\Desktop\carton.txt"
F= open(file_path, 'r')
found = False
row = csv.reader(F)
if data[0] == no:
print("\t**********************")
print("\tEMP_No:", data[0])
print("\tName:", data[1])
print("\tSalary:", data[2])
print("\t**********************")
found = True
break
if not found:
Create()
Search()
Table : Student
(b) Write a Query to list name of the students whose ages are between 18 to 20.
(c) Write a Query to display the name of the students whose name is starting with 'A'.
(d) Write a query to list the names of those students whose name have second alphabet 'n' in
their
names.
SQL
Dept VARCHAR(50),
);
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
INSERT INTO Student (Rollno, Name, Gender, Age, Dept, DOA, Fees)
a) SELECT Name FROM Student WHERE Gender = 'F' AND Dept = 'HINDI';
1. Write a Python program to implement Stack using a list data-structure, to perform the
following operations:
(i) Push an object containing DocID and Doc_name of doctors who specialize in "ENT" to
the stack.
(ii) To Pop the objects from the stack and display them.
(iii) To display the elements of the stack (after performing PUSH or POP)
def Push():
if Special=='ENT'or 'ent':
Stack.append([Doc_ID,Doc_Name])
def Pop():
if Stack==[]:
print("Stack is empty")
else:
def Peek():
if Stack==[]:
print("Stack is empty")
else:
top=len(Stack)-1
def Disp():
if Stack==[]:
print("Stack is empty")
else:
top=len(Stack)-1
for i in range(top,-1,-1):
print(Stack[i])
Stack=[]
ch='y'
print()
print("1.PUSH")
print("2.POP")
print("3.PEEK")
print("4.Disp")
if opt==1:
Push()
elif opt==2:
Pop()
elif opt==3:
Peek()
elif opt==4:
Disp()
else:
print("Invalid Choice, Try Again!!!")
Table : Student
SQL
(b) Write a Query to change the fess of Student to 170 whose Roll number is 1,
if the existing fess is less than 130.
b) UPDATE Student SET Fees = 170 WHERE Rollno = 1 AND Fees < 130;
(c) Write a Query to add a new column Area of type varchar in table STU
(d) Write a Query to delete Area Column from the table STU.