SHARE
TWEET

Average

elena_gancedo Jun 26th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Hi, I am Eley, your personal bot.")
  2. command = input("How can I help? ")
  3. if command == "add" or command == "plus":
  4.     print("lets add some numbers")
  5.     input1 = input("Number 1> ")
  6.     input2 = input("Number 2> ")
  7.     number1 = int(input1)
  8.     number2 = int(input2)
  9.     result = number1 + number2
  10.     output = str(result)
  11.     print(input1 + " + " + input2 + " = " + output)
  12. elif command == "average":
  13.     how_many = input("How many numbers> ")
  14.     how_many = int(how_many)
  15.     total = 0
  16.     for number_count in range(how_many):
  17.         number = input("Enter number " + str(number_count) + "> ")
  18.         total = total + int(number)
  19.     result = total / how_many
  20.     print("the average = " + str(result))
  21. else:
  22.     print("Sorry your entry is wrong.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top