Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to define a function to calculate the area of a triangle, followed by inputing the height and base to calculate the output. However, it doesn't produce any result, I wonder if I'm correct?

def tri_area(base, height):
    return  base * height / 2

tri_area(2, 3)
Posted

1 solution

Open ipython console and type:
In [1]: def tri_area(base, height):
   ...:     return  base * height / 2

close the line with Shift + Return and type the next line
In [2]: tri_area(2, 3)

and close it with Return. You will see your output:
Out[2]: 3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900