Q.

1
def countvowel(names):
tvow=i=0
print("names are....")
nlen=len(names)
while(i<nlen):
print(names[i])
nst=str(names[i])#converts string into list
slen=len(nst)
j=0
while(j<slen):
ch=nst[j].lower()
if(ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u'):
tvow += 1
j += 1
i += 1
return tvow
names=[]
opt='y'
while opt=='y' or opt=='Y':
nm=list(raw_input("enter name:"))

names.append(nm)#adding name into list names
opt=raw_input("want to add more name<y/n>")
ctr = countvowel(names)
print('total number of vowel in the name list is:',ctr)

Q.2

pow(x.i)/fact sum=sum+p print("sum of sereies is->".n+1): fact=1 t=i+1 for j in range(1.3 ch="y" while(ch=="y"): .import math n=int(input("enter the value of n=>")) x=int(input("enter the value of x=>")) p=1 sum=1 for i in range(1.sum) Q.t+1): fact=fact*j p=math.

s elif n==3: h=input("enter the hight") b=input("enter the base") s=(h*b)/2 print"area of triangle".area of square" print"2.area of triangle" n=input("enter the choice:") if(n==1): a=input("enter the side of square") s=a*a print"area of square".s elif n==2: x=input("enter the length") y=input("enter the breadth") s=x*y print"area of rectangle ".area of rectangle" print"3.s else: print"invalid input" ch==raw_input("if you want to drive the programme again press y otherwise any other key") .print"1.

4 class COMPETITION: event_no =0 score = 0 description ="" qualified = "" def Clinput(self): .Q.

Award Cm.qualified = 'Y' else: self.self.qualified) Cm=COMPETITION() Cm.score > cut_off): self.score) print("Qualified:".self.:") self.Clinput() Cut_off = int(input("Enter cut_off score:")) Cm.Show() .description) print("score:".event_no = int(input("Enter event no.self.:")) self.self.self.:".score=int(input("Enter score :")) def Award(self): if(self.qualified ='N' def Show(self): print("Event no.desciption = raw_input("Enter description.event_no) print("Description:".

busno=int(input("enter bus no.travelfrom = raw_input("enter the place of origin:") self.btype = raw_input("enter bus type:") self.__calcfare() def __calcfare(self): if(self.5 : class transport: busno=0 distance=0 fare=0 travelfrom = 'none' travelto = 'none' btype = 'none' def __init__(self): self.btype='0' self.travelto = raw_input("enter destination place:") self.distance = int(input("enter distance:")) self.:")) self.fare=500 def seatallocate(self): print() self.btype=="0"): .Q.

fare) t=transport() t.distance) print("bus fare:".self.sname=" ".fare = self.travelto) print("bustype:".self.srollnum=0.busno) print("bus travel from:".distance*24 def showticket(self): print("bus no.travelfrom) print("travel to:".btype=="s"): self.self.fare = self.self.:".self.6 class student(object): def __init__(self.seatallocate() t.fare = self.showticket() Q.distance*15 elif(self.self.self.distance*20 elif(self.btype) print("distance travel:".btype=="d"): self.smarks=0): pass def acceptdata(self): .

scfathername=" "): student.srollnum=0.self.self.acceptdata(self) self.self.displaydata(self) print "father's name ".smarks=0) pass def scholardata(self): student.srollnum print"student name".scfathername else: print"marks not greater than 80" def main(): s=scholar() .sname=" ".sname print"student marks".__init__(srollnum=0.scfathername=raw_input("enter student father name") def printscholar(self): if (self.self.smarks class scholar(student): def __init(self.sname=raw_input("enter the student name") self.smarks=input("enter your 10 marks") def displaydata(self): print"student roll number".smarks=0.srollnum=input("enter the roll number") self.self.sname=" ".smarks>80): student.

scholardata() print"printing detail" s.printscholar() main() Q.ctr+1."position from begining" break if flag==0: print"element not found" datalist=[] .s.8 def linearsearch(datalist.item): flag=0 ctr=0 for ctr in range(n): if datalist[ctr]==item: flag==1 print"element found at".

of element") for i in range(n): num=input("enter number") datalist.value): low=0 flag=0 value=0 high=len(datalist)-1 while (low<=high): mid=int(low+high)/2 if datalist[mid]==value: print value.mid+1 flag==1 break if datalist[mid]>value: high=mid-1 .n= input("enter no.append(num) item=input("enter number to be searched") linearsearch(datalist.9 def bsearch(datalist."found at pos".item) Q.

of element") for i in range(n): num=input("enter number") datalist.if datalist[mid]<value: low=mid+1 if flag==0: print"not found" datalist=[] n= input("enter no.value) .append(num) value=input("enter number to be searched") bsearch(datalist.

Q.append(list1[i]*2) print c l=list(input("enter list of values")) array(l) .l): if list1[i]%5==0: c.10 def array(list1): c=[] l=len(list1) for i in range(0.append(list1[i]/5) else: c.

11 s=[] c="y" while(c=="y"): print"1.pop() elif(choice==3): l=len(S) for i in range(l-1.s.push" print"2.Q.pop" print"3.append(a) elif(choice==2): if(s==[]): print"stack empty" else: print"deleted element is:".-1): print s[i] .display" choice=input("enter your choice:") if(choice==1): a=input("enter any number:") s.-1.

else: print("wrong input") c=raw_input("do you want to continue or not? ") .

append(b) elif(choice==2): if(a==[]): print("queue empty") else: print"deleted element is:".insert" print"2.a[0] del a[0] elif(choice==3): l=len(a) for i in range(0.Q.12 a=[] c='y' while c=='y': print"1.delete" print"3.1): print a[i] .display" choice=input("enter your choice") if(choice==1): b=input("enter new number") a.

else: print("wrong input") c=raw_input("do you want to continue or not") .

"+name.write(str(rollno)+".upper()+"-"+str(marks) +"\n") fobj.:") name = raw_input("enter name:") marks = input("enter marks:") fobj.flush() ch=raw_input("add more record?<y/n>:") ch=ch.upper() if ch=='y': continue .txt" fobj=open(file.13 import os file="student.'a') if not file: print("file does not created") else: ctr = 1 print("enter student information") ch='y' while ch=='y': rollno = input("enter the roll no.Q.

isfile(file): .path.close() Q.else: break fobj.14 import os file ="student.txt" if os.

16 flag = False while not flag: numberstring = raw_input("enter an integer") try: a = int(numberstring) flag = True except: .fobj = open(file) print("student information") print("********************") for student in fobj: print(student) fobj.close() else: print("File does not exist.") Q.

print("error.invalid integer") Q.n+1): yield i**3 n=int(input("enter a number to generate cube over time:")) for i in cubic_generator(n): print(i) .17 def cubic_generator(n): for i in range(1.