Advertisement
TonyMo

1 7 TriAreaDefRet.py

Mar 15th, 2021
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # Python 102 1 7 Challenge
  2. ''' Create a _function_ that accepts the dimensions of a triangle and _returns_ its area.
  3. Note: The formula for the area of a triangle is base*height/2 '''
  4.  
  5. def tarea():
  6.     base = float(input(" input triangle Base dimension : "))
  7.     print("You entered : ", base)
  8.     height = float(input("input triangle Height dimension : "))
  9.     print("You entered : ", height)
  10.     area = (base * height)/2
  11.     # print("Triangle area is: ", area)
  12.     return area
  13.  
  14. a = tarea()
  15. print("Area =", a)
  16.  
  17. # Note: there is no error handling; as for strings or negative numbers !
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement