In [ ]:
#12c1 program to create tuple storing n term of fibbonacci sequence
n=int(input('enter number of term for Sequence'))
a=0
b=1
t=()
for i in range(1,n+1):
if(i==1):
t+=(a,)
elif(i==2):
t+=(b,)
else:
c=a+b
t+=(c,)
a=b
b=c
print("the Created Tuple is",t)
In [ ]:
#12c3 program to
n=int(input('enter number of student'))
marks=()
for i in range(1,n+1):
m1= eval(input('input number for three subject in tuple format'))
marks+=(m1,)
print("the Created Tuple is",marks)
for j in range(0,n):
s=marks[j][0]+marks[j][1]+marks[j][2]
print('sum of marks ',s)
print('average of marks',s/3)
In [ ]:
#12c4 program to total marks and average of each tuple
n=int(input('enter number of term for Sequence'))
marks=()
for i in range(1,n+1):
m1= eval(input('input number for three subject in tuple format'))
marks+=(m1,)
print("the Created Tuple is",marks)
#summation and average tuplewise
l=len(marks)
s=0
avg=0
for j in range(l):
s=0
s+=marks[j][0]+marks[j][1]+marks[j][2]
print('sum of marks for',j+1,'student is',s,'and average is',s/3)
In [ ]:
#12c4 program to total marks and average of each tuple
n=int(input('enter number of term for Sequence'))
marks=()
for i in range(1,n+1):
m1= eval(input('input number for three subject in tuple format'))
marks+=(m1,)
print("the Created Tuple is",marks)
#summation and average tuplewise
l=len(marks)
s=0
avg=0
for j in range(l):
s=0
s+=marks[j][0]+marks[j][1]+marks[j][2]
print('sum of marks for',j+1,'student is',s,'and average is',s/3)
In [ ]:
#12c4 program to total marks and average of each tuple
n=int(input('enter number of term for Sequence'))
marks=()
for i in range(1,n+1):
m1= eval(input('input number for three subject in tuple format'))
marks+=(m1,)
print("the Created Tuple is",marks)
#summation and average tuplewise
l=len(marks)
s=0
avg=0
for j in range(l):
s=0
s+=marks[j][0]+marks[j][1]+marks[j][2]
print('sum of marks for',j+1,'student is',s,'and average is',s/3)
In [ ]:
#program allow to enter product name and price each time and ask user to enter
#product name and print concerned price ,if its not in dictionary its print
#a message that 'its not in dictionary'
d={}
while True:
p=input('enter product name or quit for exit')
pr=input('price of product')
d[p]=pr
if(p=='quit'):
break
while True :
search=input('enter product to be searched')
print(d.get(search,'not found in dictionary'))
if(search=='quit'):
break
In [ ]:
#13c3 create dictionary of month name and day in month ,print all keys in
#alphabetical order,print all month with 31 days,print key,value pair sorted
#by number of days in each month
dm={}
while True:
m=input('input month name or Q to exit')
if(m=='Q'):
break
d=input('Day in month')
dm[m]=d
print(dm)
#list creation of keys
kl=list(dm.keys())
kl.sort()
print('All month key in alphabetical order',kl)
#print all month with 31 days
for n in dm:
if(dm[n]=='31'):
print(n)
No comments:
Post a Comment