Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. finished = False
  2. while finished == False:
  3. print("Hi, I am Jenny, your personal bot.")
  4. command = input("How can I help? ")
  5. # code for adding numbers
  6. if command == "add":
  7. print("Let's add some numbers!")
  8. users_name = input("What is your name? ")
  9. print("Welcome to Math world, " + users_name)
  10. print("Let's add some numbers.")
  11. input1 = input("Number1- ")
  12. input2 = input("Number2- ")
  13. input3 = input("Number3- ")
  14. number1 = int(input1)
  15. number2 = int(input2)
  16. number3 = int(input3)
  17. result = number1 + number2 + number3
  18. output = str(result)
  19. print(input1 + "+" + input2 + "+" + input3 + "=" + output)
  20. # elif is like having possibilities other than the first one
  21. # code for subtracting numbers
  22. elif command == "subtract":
  23. print("Let's subtract some numbers.")
  24. input1 = input("Number1- ")
  25. input2 = input("Number2- ")
  26. number1 = int(input1)
  27. number2 = int(input2)
  28. result = number1 - number2
  29. output = str(result)
  30. print(input1 + "-" + input2 + "=" + output)
  31.  
  32. # code for multiplying numbers
  33. elif command == "multiply":
  34. print("Let's multiply some numbers.")
  35. input1 = input("Number1- ")
  36. input2 = input("Number2- ")
  37. number1 = int(input1)
  38. number2 = int(input2)
  39. result = number1*number2
  40. output = str(result)
  41. print(input1 + "X" + input2 + "=" + output)
  42.  
  43. # code for dividing numbers
  44. elif command == "division":
  45. print("Let's divide some numbers.")
  46. input1 = input("Number1- ")
  47. input2 = input("Number2- ")
  48. number1 = int(input1)
  49. number2 = int(input2)
  50. result = number1/number2
  51. output = str(result)
  52. print(input1 + "/" + input2 + "=" + output)
  53.  
  54. # code for calculating area of a triangle
  55. elif command == "area of a triangle":
  56. print("Let's calculate the area of a triangle.")
  57. print("The formula for the area of a triangle is: 1/2 X Base X Height.")
  58. input1 = input("Base- ")
  59. input2 = input("Height- ")
  60. number1 = int(input1)
  61. number2 = int(input2)
  62. result = (1/2)*number1*number2
  63. output = str(result)
  64. print("1/2 X " + input1 + "X" + input2 + "=" + output)
  65.  
  66. # code for finding average
  67. elif command == "average":
  68. print("Let's learn about average.")
  69. how_many = input("How many numbers?> ")
  70. how_many = int(how_many)
  71. total = 0
  72. for number_count in range(how_many):
  73. number = input("Enter number " + str(number_count) + ">")
  74. total = total + int(number)
  75. result = total / how_many
  76. print("the average=" + str(result))
  77.  
  78. # to create a shopping list
  79. elif command == "create shopping list":
  80. print("Let's create a shopping list.")
  81. shopping = []
  82. count = 0
  83.  
  84. how_many = input("How many items of shopping do you have? ")
  85. how_many = int(how_many)
  86.  
  87. for item_number in range(how_many):
  88. item = input("What is the item number " + str(item_number) + "?")
  89. shopping.append(item)
  90. count = count + 1
  91.  
  92. output = str(count)
  93. print(shopping)
  94. print("You have " + output + " items in your shopping list.")
  95. elif command == "bye":
  96. finished = True
  97. else:
  98. print("I don't understand")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement