Calling functions

I have another question. How do I call my functions? They are showing blank. Here is the code:

def area_of_triangle():
    b = input("Base: ")
    h = input("Height: ")
    area =  0.5 * float(b) * float(h)
    return "The area of the triangle is " + str(area) + "."

def area_of_square():
    l = input("Length: ")
    w = input("Width: ")
    area = l * w
    return "The area of the square is " + str(area) + "."

formula = input("Please type the equation you would like to do. If you dont know type help. ")
if input == "triangle":
if formula == "square":
if formula == "help":
                print("To find the area of a triangle, type the word triangle. To find the area of a square, type the word square.")

I think that you may need to do print(stuff) instead of return stuff in your functions to make stuff show up on the screen.
Alternatively, when calling the function, you could do something like

if formula == "triangle":
                print( area_of_triangle() )

Otherwise, it seems fine to me, assuming you’re going for user input using input.
Although if you are not, you could do something simpler:

def area_of_rectangle(length, width): return length * width #calling the function with arguments 5 and 10: area = area_of_rectangle(5, 10) print(area)

if input == "triangle":
should be
if formula == "triangle":

1 Like

Thank you. I will try a print statement to see if it works. And yes, I am looking for user input.

That worked, thank you very much!