Advertisement
zhongnaomi

def total average

Jan 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. def do_calculation():
  2.    
  3.     R1 = input ( "How many numbers?> ")
  4.     numbers = []
  5.     total = 0
  6.    
  7.     for item_number in range(int(R1)):
  8.         item = input("Enter number >")
  9.         numbers.append(item)
  10.         total = total + int(item)
  11.     if command == "total":
  12.    
  13.         result = total
  14.  
  15.     elif command == "average":
  16.         result = total / int(R1)  
  17.     print(command + "=" + str(result) )    
  18. finished = False
  19. while finished == False :
  20.     print("Hi, I am Marvin, your personal bot.")
  21.     command = input("How can I help? ")
  22.     if command == "total":  
  23.         do_calculation()      
  24.     elif command == "average":
  25.         do_calculation()
  26.     elif command == "bye" :
  27.         finished = True
  28.     else :
  29.         print ("Sorry I do not understand this " )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement