Advertisement
Roddyn

bot_area_of_triangle

Dec 9th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. print("Hi, I am Marvin, your personal bot.")
  2.  
  3. #asks and prints users name
  4. user_name = input ("What is your name? ")
  5. print("Welcome " + user_name )
  6.  
  7. #input a calculation type
  8. command = input("How can I help? ")
  9.  
  10. #when input add does an addition calculation
  11. if command == "add":
  12. print("let's add some numbers")
  13. input1 = input("Number 1> ")
  14. input2 = input("Number 2> ")
  15. number1 = int(input1)
  16. number2 = int(input2)
  17. result = number1 + number2
  18. output = str(result)
  19. print(input1 + " + " + input2 + " = " + output)
  20.  
  21. #when input subtract does a suntraction calculation
  22. elif command == "subtract":
  23. print("let's subtract some numbers")
  24. input1 = input("Number 1> ")
  25. input2 = input("Number 2> ")
  26. number1 = int(input1)
  27. number2 = int(input2)
  28. result = number1 - number2
  29. output = str(result)
  30. print(input1 + " - " + input2 + " = " + output)
  31.  
  32. #when input multiply does a multiply calculation
  33. elif command == "multiply":
  34. print("let's Multiply some numbers")
  35. input1 = input("Number 1> ")
  36. input2 = input("Number 2> ")
  37. number1 = int(input1)
  38. number2 = int(input2)
  39. result = number1 * number2
  40. output = str(result)
  41. print(input1 + " * " + input2 + " = " + output)
  42.  
  43. #when input subtract does asubtraction calculation
  44. elif command == "subtract":
  45. print("let's subtract some numbers")
  46. input1 = input("Number 1> ")
  47. input2 = input("Number 2> ")
  48. number1 = int(input1)
  49. number2 = int(input2)
  50. result = number1 - number2
  51. output = str(result)
  52. print(input1 + " - " + input2 + " = " + output)
  53.  
  54. #when input triangle calculates the are of a right angled triangle
  55. elif command == "triangle":
  56. print("let's find the area of a right angled triangle")
  57. input1 = input("Base of the triangle> ")
  58. input2 = input("Height of the triangle> ")
  59. number1 = int(input1)
  60. number2 = int(input2)
  61. result = (number1 * 0.5) * number2
  62. output = str(result)
  63. print("(" + input1 + " * 0.5) *" + input2 + " = " + output)
  64. # if neither add or subtract outputs an apology
  65. else:
  66. print ("sorry I can't do that yet!!!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement