Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- prints layout
- """
- def printHeader(n):
- print(n)
- #printing layout
- print('-'*40)
- print("List Of medicines above average price")
- print('-'*40)
- print("Medicine Quantity Unit price Total Price")
- print('-'*40)
- """
- takes list returns index of max element
- """
- def positionMax(q):
- t=max(q)#finds max
- for i in range(len(q)):
- if t==q[i]:# finds index and return it
- return i
- """
- main func
- """
- def main():
- print("Enter pharmacy name")#take input
- ans=input()
- name,q,up,tp=[],[],[],[]#medicine name,quant,unit price,total price
- for i in range(5):
- print("Enter medicine name,quantity and unit price")
- a,b,c=input().split(',')#take input form screen
- b,c=int(b),float(c)
- name.append(a)#appending to the lists
- q.append(b)
- up.append(c)
- tp.append(b*c)
- ap=sum(tp)/5#find avvg
- printHeader(ans)#header format
- #print table
- for i in range(5):
- print("{}\t\t{}\t\t{}\t\t{}".format(name[i],q[i],up[i],tp[i]))
- print('-'*40)
- print("Overall Average price",ap)
- idx=positionMax(tp)
- print("The maximum price is {} for {}".format(tp[idx],name[idx]))
- """
- driver func
- """
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement