Computer Science Practical File: Name - Vivek Bhagat Class - XII-A Roll No - 27
Computer Science Practical File: Name - Vivek Bhagat Class - XII-A Roll No - 27
Computer Science Practical File: Name - Vivek Bhagat Class - XII-A Roll No - 27
OUTPUT
17
2
9
1
3
CSV
#To add room number ,room status and patient name to
hospital.csv
cw.writerow([rno,'EMPTY',name]) f.close()
for i in cr:
print(i[0],i[1],i[2]) flag=1
if flag==0: print('Not found')
f.close()
cw=csv.writer(g)
rn=int(input('Enter room number to update '))
flag=0
for I in cr:
if int(i[0])==rn: flag=1
print('Old record',i)
k=input('Press "Y" if room occupied and "N" if not ')
if k.upper()=='Y': i[1]='OCCUPIED'
i[2]='N.A'
cw.writerow(i) else: cw.writerow(i)
f.close() g.close() if flag==0: print('Not
found') else: os.remove('hospital.csv')
os.rename('h.csv','hospital. csv')
for i in cr:
if i[1]=='EMPTY':
c=c+1
print('Room Number',i[0],'is Empty') if c==0:
print('6.EXIT')
def add():
f=open('books.dat','ab') while True: bno=int(input('Enter
Book Number ')) bname=input('Enter Book Name ')
n=int(input('Enter Number of book Copies Available
'))
pickle.dump([bno,bname,n],f)
m=input('Want to add more (Y/N) ') if m.upper()=='N':
break f.close()
def show():
f=open('books.dat','rb')
try: while True:
s=pickle.load(f)
try:
while True:
s=pickle.load(f) if s[0]==b:
flag=1
print(s[1],'( Book Number',s[0],') has',s[2],'Copies left')
except:
if flag==0:
print('Book Not Found') f.close()
g.close()
if flag==0:
print('Book Not Found')
os.remove("books.dat")
os.rename('t.dat','books.dat')
while True:
print('PRESS') print('1.ADD')
print('2.SHOW')
print('3.SEARCH')
print('4.REMOVE')
print('5.EXIT')
if q==1:
add()
elif q==2:
show()
elif q==3:
search()
elif q==4:
remoove()
elif q==5:
break else:
print('Invalid Input')
OUTPUT
STACK
#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.Also write
functions for show and pop for the same.
OUTPUT
DICTIONARY
#Write a program to ask roll number and name of n students and print
them
WORKER
WORKER
PREDICT OUTPUT
#SELECT COUNT(*),DCODE FROM WORKER GROUP BY DCODE
HAVING COUNT(*)>1;
#SELECT DISTINCT DEPARTMENT FROM DEPT;
#SELECT NAME, DEPARTMENT,CITY FROM WORKER,DEPT WHERE
W.CODE=D.CODE AND WNO<1003;
#SELECT MAX(DOJ),MIN(DOB) FROM WORKER;
OUTPUT
IN BUILT FUNCTIONS