Advertisement
banjothorn

Untitled

Nov 1st, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1.  
  2. print("Hi I am John B, your personal bot.")
  3. print("lets get started.")
  4. print(" ")
  5. print(" ")
  6.  
  7. users_name = input("How would you like to be addressed? ")
  8. print(" ")
  9. print(" ")
  10. print("Welcome " + users_name + " and lets go on an adventure")
  11.  
  12. finished = False
  13. while finished == False:
  14. print("Available commands are - add or subtract or average or highest . ")
  15. print(" to stop the program enter quit.")
  16. command = input("Enter a command:- ")
  17. if command == "add" or command == "plus":
  18. input1 = input("number 1> ")
  19. number1 = int(input1)
  20. input2 = input("number 2> ")
  21. number2 = int(input2)
  22. result = number1 + number2
  23. print(" ")
  24. output = str(result)
  25. print(input1 + "+" + input2 + "=" + output)
  26. elif command == "subtract":
  27. input1 = input("number 1> ")
  28. number1 = int(input1)
  29. input2 = input("number 2> ")
  30. number2 = int(input2)
  31. result = number1 - number2
  32. print(" ")
  33. output = str(result)
  34. print(input1 + "-" + input2 + "=" + output)
  35. elif command == "average":
  36. how_many = input("How many numbers ? ")
  37. how_many = int(how_many)
  38. total = 0
  39. for number_count in range(how_many):
  40. number = input("Enter number " + str(number_count) + "> ")
  41. total = total+int(number)
  42. result = total/how_many
  43. print("The average = " + str(result))
  44. elif command == "highest":
  45. target = 0
  46.  
  47. how_many = input("How many numbers ? ")
  48. how_many = int(how_many)
  49. total = 0
  50.  
  51. for number_count in range(how_many):
  52. number = input("Enter number " + str(number_count) + "> ")
  53. # print("targ 1 " + str(target))
  54. if target < int(number):
  55. target = int(number)
  56. # print("targ 2 " + str(target))
  57.  
  58. print("The highest = " + str(target))
  59. elif command == "quit":
  60. finished = True
  61. else:
  62. print("sorry not a valid command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement