Tom_Jung

FutureLearn_MathBot_Areas

Jan 8th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. print("Hi, I am R2D2, your personal math bot")
  2.  
  3. command = input("You may direct me to calculate the area of a circle or triangle: ")
  4.  
  5. if command == "triangle":
  6. print("Please enter the base and height when requested")
  7.  
  8. base = int(input("base of triangle: "))
  9. height = int(input("height of triangle: "))
  10.  
  11. tri_area = 0.5 * base * height
  12.  
  13. print("Area of triangle with base =", base, "&" ,"height =",height,"is", tri_area)
  14.  
  15. elif command == "circle":
  16. print("Please enter the diameter of the circle: ")
  17.  
  18. diameter = int(input("diameter of circle: "))
  19.  
  20. cir_area = 3.14 * (0.5 * diameter)**2
  21.  
  22. print("Area of circle with diameter =",diameter, "is", cir_area)
  23.  
  24. else:
  25. print("Sorry, this is the area math bot for a triangle or circle")
Add Comment
Please, Sign In to add comment