Advertisement
Iam_Sandeep

Untitled

Dec 7th, 2021
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. """
  2. prints layout
  3. """
  4. def printHeader(n):
  5.     print(n)
  6.     #printing layout
  7.     print('-'*40)
  8.     print("List Of medicines above average price")
  9.     print('-'*40)
  10.     print("Medicine Quantity Unit price Total Price")
  11.     print('-'*40)
  12. """
  13. takes list returns index of max element
  14. """
  15. def positionMax(q):
  16.     t=max(q)#finds max
  17.     for i in range(len(q)):
  18.         if t==q[i]:# finds index and return it
  19.             return i
  20. """
  21. main func
  22. """
  23. def main():
  24.     print("Enter pharmacy name")#take input
  25.     ans=input()
  26.     name,q,up,tp=[],[],[],[]#medicine name,quant,unit price,total price
  27.     for i in range(5):
  28.         print("Enter medicine name,quantity and unit price")
  29.         a,b,c=input().split(',')#take input form screen
  30.         b,c=int(b),float(c)
  31.         name.append(a)#appending to the lists
  32.         q.append(b)
  33.         up.append(c)
  34.         tp.append(b*c)
  35.     ap=sum(tp)/5#find avvg
  36.     printHeader(ans)#header format
  37.     #print table
  38.     for i in range(5):
  39.         print("{}\t\t{}\t\t{}\t\t{}".format(name[i],q[i],up[i],tp[i]))
  40.     print('-'*40)
  41.     print("Overall Average price",ap)
  42.     idx=positionMax(tp)
  43.     print("The maximum price is {} for {}".format(tp[idx],name[idx]))
  44. """
  45. driver func
  46. """
  47. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement