Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. print("Hi, I am Jenny, your personal bot.")
  2. command = input("How can I help? ")
  3. # code for adding numbers
  4. if command == "add":
  5. print("Let's add some numbers!")
  6. users_name = input("What is your name? ")
  7. print("Welcome to Math world, " + users_name)
  8. print("Let's add some numbers.")
  9. input1 = input("Number1- ")
  10. input2 = input("Number2- ")
  11. input3 = input("Number3- ")
  12. number1 = int(input1)
  13. number2 = int(input2)
  14. number3 = int(input3)
  15. result = number1 + number2 + number3
  16. output = str(result)
  17. print(input1 + "+" + input2 + "+" + input3 + "=" + output)
  18. # elif is like having possibilities other than the first one
  19. # code for subtracting numbers
  20. elif command == "subtract":
  21. print("Let's subtract some numbers.")
  22. input1 = input("Number1- ")
  23. input2 = input("Number2- ")
  24. number1 = int(input1)
  25. number2 = int(input2)
  26. result = number1 - number2
  27. output = str(result)
  28. print(input1 + "-" + input2 + "=" + output)
  29.  
  30. # code for multiplying numbers
  31. elif command == "multiply":
  32. print("Let's multiply some numbers.")
  33. input1 = input("Number1- ")
  34. input2 = input("Number2- ")
  35. number1 = int(input1)
  36. number2 = int(input2)
  37. result = number1*number2
  38. output = str(result)
  39. print(input1 + "X" + input2 + "=" + output)
  40.  
  41. # code for dividing numbers
  42. elif command == "division":
  43. print("Let's divide some numbers.")
  44. input1 = input("Number1- ")
  45. input2 = input("Number2- ")
  46. number1 = int(input1)
  47. number2 = int(input2)
  48. result = number1/number2
  49. output = str(result)
  50. print(input1 + "/" + input2 + "=" + output)
  51.  
  52. #code for calculating area of a triangle
  53. elif command == "area of a triangle":
  54. print("Let's calculate the area of a triangle.")
  55. print("Firstly, the formula for the area of a triangle is: 1/2 X Base X Height.")
  56. input1 = input("Base- ")
  57. input2 = input("Height- ")
  58. number1 = int(input1)
  59. number2 = int(input2)
  60. result = (1/2)*number1*number2
  61. output = str(result)
  62. print("1/2 X " + input1 + "X" + input2 + "=" + output)
  63.  
  64. else:
  65. print("I don't understand.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement