Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python 102 1 7 Challenge, 1_7_TriAreaDefRet2.py
- # Was 1_7_TriAreaDefRet1.py https://pastebin.com/EDhh2FjN
- ''' Create a _function_ that accepts the dimensions of a triangle and _returns_ its area.
- Note: The formula for the area of a triangle is base*height/2 '''
- '''
- Hi @TonyMoody. The function should take the base and height of the triangle as parameters, rather than asking for user input during the function '''
- def tarea(base, height):
- area = (base * height)/2
- # print("Triangle area is: ", area) OK within def.
- return area
- # Test the function tarea()
- # b = 20 # also works OK
- # h = 30 # also works OK
- b = float(input("base ? :"))
- h = float(input("height ? :"))
- a = tarea(b, h) # this 'a' == 'area' in the def tarea()
- print("Area =", a)
- '''
- >>>
- Area = 300.0
- >>>
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement