Advertisement
banjothorn

Untitled

Nov 1st, 2018
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. def do_calc2():
  2. how_many = input("How many numbers ? ")
  3. how_many = int(how_many)
  4. total = 0
  5. result = 0
  6. for number_count in range(how_many):
  7. number = input("Enter number " + str(number_count) + "> ")
  8. total = total+int(number)
  9. if command == "average":
  10. result = total/how_many
  11. print("The average = " + str(result))
  12. elif command == "total":
  13. result = total
  14. print("The Total = " + str(result))
  15.  
  16. def do_calculation():
  17. print("Lets " + command + " some numbers.")
  18. input1 = input("Number 1>")
  19. input2 = input("Number 2>")
  20. number1 = int(input1)
  21. number2 = int(input2)
  22. if command == "add":
  23. result = number1 + number2
  24. operator = " + "
  25. elif command == "subtract":
  26. result = number1 - number2
  27. operator = " - "
  28. output = str(result)
  29.  
  30. print(input1 + operator + input2 + " = " + output)
  31.  
  32. print("Hi I am John B, your personal bot.")
  33. print("lets get started.")
  34. print(" ")
  35. print(" ")
  36.  
  37. users_name = input("How would you like to be addressed? ")
  38. print(" ")
  39. print(" ")
  40. print("Welcome " + users_name + " and lets go on an adventure")
  41.  
  42. finished = False
  43. while finished == False:
  44. print("Available commands are - add or subtract or average or total or highest. ")
  45. print(" to stop the program enter quit.")
  46. command = input("Enter a command:- ")
  47. if command == "add" or command == "plus":
  48. do_calculation()
  49. elif command == "subtract":
  50. do_calculation()
  51. elif command == "average":
  52. # how_many = input("How many numbers ? ")
  53. # how_many = int(how_many)
  54. total = 0
  55. # how_many = 0
  56. # for number_count in range(how_many):
  57. # number = input("Enter number " + str(number_count) + "> ")
  58. # total = total+int(number)
  59. do_calc2()
  60. # print(int(how_many))
  61.  
  62. # result = total/how_many
  63. # print("The average = " + str(result))
  64. elif command == "total":
  65. # how_many = input("How many numbers ? ")
  66. # how_many = int(how_many)
  67. total = 0
  68. # for number_count in range(how_many):
  69. # number = input("Enter number " + str(number_count) + "> ")
  70. # total = total+int(number)
  71. # result = total
  72. # print("The Total = " + str(result))
  73. do_calc2()
  74. elif command == "highest":
  75. target = 0
  76.  
  77. how_many = input("How many numbers ? ")
  78. how_many = int(how_many)
  79. total = 0
  80.  
  81. for number_count in range(how_many):
  82. number = input("Enter number " + str(number_count) + "> ")
  83. # print("targ 1 " + str(target))
  84. if target < int(number):
  85. target = int(number)
  86. # print("targ 2 " + str(target))
  87.  
  88. print("The highest = " + str(target))
  89. elif command == "quit":
  90. print("Thank you " + users_name + " and goodbye.")
  91. finished = True
  92. else:
  93. print("sorry not a valid command")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement