0% found this document useful (0 votes)
19 views5 pages

Practicallist

prac

Uploaded by

mahikanagar123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Practicallist

prac

Uploaded by

mahikanagar123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

a)Def list():
f = open(“poem.txt”,'r+')
f.write('Neither apple nor pine are in pineapple. Boxing rings are
square. Writers write but fingers don’t fing. Overlook and oversee
are opposites. A house can burn up as it burns down. An alarm goes
off by going on.')
f2=f.readlines()
print(f2)

b)f=open(“poem.txt”, ‘a’)
f.write(‘n\alarm clock is black’)
f=open(“poem.dat”)
f2=f.readlines()
for i in range (len(f2)):
print(i+1,f2(i))

c)print(f2[-1])
d)f=open(“poem.txt”,'r')
f.seek(10)
f2=f.readline()
print(f2)

e)def doc(4):
f=open(“poem.txt”, ‘r’)
f2=f.readlines()
s=int(input('Enter the line number:'))
print f2(s)

f)f=open('poem.txt','r')
f2=f.read()
dict={}
for i in line:
dict[i]=0
for i in line:
dict[i]+=1
print(dict)

2. f=open('file1.txt','w')
f.write('do not Carry Umbrella and Overcoat When it does not rain')
f.close()

def isvowel(f):
f2=open('file2.txt','w')
list= ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
vowel=[]
f3=f.read()
l2=f3.split()
for i in l2:
if l2(i[0]) in list:
vowel+=1
else:
f.write(i+' ')]
f2.close()

f2=open('file2.txt','r')
a=f2.read()
print('Contents of file1: do not Carry Umbrella and Overcoat
when it does not Rain')
print('Contents of file2:',a)

3.
11/30/2020
DhruvKikan.ipynb - Colaboratory
a=open('filel.txt','w')a.write('do not Carry Umbrella and Overcoat
When it does notRain') a.close()def isvovel(a):
b=open('file2.txt','w')
vovellst=[65,69,73,79,85,97,101,105,111,117]
w=a.read()
k=w.split()
for y ink:
if ord(y[0]) invovellst:
passelse:b.write(y+' ')b.close()
b=open('file2.txt','r')
c=b.read()print('Contents of file1: do not Carry Umbrella and
Overcoat When it does notRain') print('Contents of file2:',c)
a=open('filel.txt','r')
x=isvovel(a)Contents of filel: do not Carry Umbrella and Overcoat
When it does notRain Contents of file2: do not Carry When does
not Rain

3.f=open('tuples.txt','w')
f.writelines(”Rajat Sen 12345 1 CSEE, \nJagat Narain 13467 3
CSEE ,\n Anu Sharma 11756 2 Biology,\nSumita Trikha 23451 4
Biology,\n Sumder Kumra 11234 3 MME ,\nKanti Bhushan 23211 3
CSEE” )
f.close()

a) f=open('tuples.txt','r')
f2=f.readlines()
l1=[]
for i in f2:
l2=i.split()
l1.append(tuple(l2))
print(l1)

5) i) customer=[{'Name':'nidhi ','RoomNo':86,'Duration' :1},


{'Name' :'Jatin','RoomNo':47,'Duration':2}]:
import pickle
f=open('Hotel.dat','wb')
pickle.dump(customer,f)
f.close()

f=open('Hotel.dat','rb')
f2=pickle.load(f)
num=int(input('Please enter a number:'))
try:
if num<=len(f2):
for i in range(num):
print(f2[i])
else:
print('Please enter a smaller number')

b)for i in f2
print(i)

c)for i in range(len(f2)):
print('There are',i+1,'people in living in the hotel')
d) for j in f2:
if j['Duration']>2:
print(j)

6.

DATABASE MANAGEMENT (MySQL)


1. use world ;
create table tutor(ID varchar(2),Namee varchar(20),Age integer,
City varchar(21), Fee integer , Phone integer) ;
alter table tutor modify phone varchar(12);
describe tutor;
Insert into tutor

values("P8","RADHA",33,"DELHI",23000,"8110668888”)

a)SELECT * from tutor WHERE age not between 35 and 40 order by


namee DESC;

b)SELECT City , avg(fee) from tutor group by city;

2)

You might also like