Advertisement
sjzmilton

Untitled

Dec 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. print("Hi, I am Zed, 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 == "subtract" or command == "minus":
  13. print("lets subtract some numbers")
  14. input1 = input("Number 1> ")
  15. input2 = input("Number 2> ")
  16. number1 = int(input1)
  17. number2 = int(input2)
  18. result = number1 - number2
  19. output = str(result)
  20. print(input1 + " - " + input2 + " = " + output)
  21. elif command == "multiply":
  22. print("lets multiply some numbers")
  23. input1 = input("Number 1> ")
  24. input2 = input("Number 2> ")
  25. number1 = int(input1)
  26. number2 = int(input2)
  27. result = number1 * number2
  28. output = str(result)
  29. print(input1 + " * " + input2 + " = " + output)
  30. elif command == "divide":
  31. print("lets divide some numbers")
  32. input1 = input("Number 1> ")
  33. input2 = input("Number 2> ")
  34. number1 = int(input1)
  35. number2 = int(input2)
  36. result = number1 / number2
  37. output = str(result)
  38. print(input1 + " / " + input2 + " = " + output)
  39. elif command == "Area":
  40. print("lets calculate the area of a triangle")
  41. input1 = input("Base > ")
  42. input2 = input("Hypotenuse > ")
  43. number1 = int(input1)
  44. number2 = int(input2)
  45. result = (number1 * number2) / 2
  46. output = str(result)
  47. print("(Base:"+input1 + " * " + "Hypotenuse:"+input2 + ") / 2" + " = " + output)
  48. elif command == "average" or command == "avg":
  49. total = 0
  50. how_many = input("how many numbers? ")
  51. how_many = int(how_many)
  52. for number_count in range(how_many):
  53. number = input("Enter number " + str(number_count) + "> ")
  54. total = total + int(number)
  55. result = total / how_many
  56. print("the average = " + str(result))
  57. elif command == "shopping" or command == "shop":
  58. total = 0
  59. shopping = []
  60. how_many = input("how many items of shopping do you have? ")
  61. how_many = int(how_many)
  62. for item_number in range(how_many):
  63. item = input("what is the item " + str(item_number) + " ? ")
  64. number = input("Enter the cost of " + str(item) + "> ")
  65. total = total + int(number)
  66. shopping.append(item)
  67. print(shopping)
  68. print("You have " + str(how_many) + " items in your shopping list. Your total is $" + str(total))
  69. else:
  70. print("sorry I dont understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement