1
degrees = float()
fahrenheit = float()
celsius = float()
meters = float()#decs.
feet = float()
selection = str()

def main():#main program
    print("Here are your choices: \n C = celsius \n M = meters \n E = exit")
    selection = input("Enter your selection")
    while selection != "e":
        if selection == "c":
            degrees(fahrenheit,celsius)
        if selection == "m":
            meters(feet,meters)
        else:
            print("Wrong input")
        selection = input("Enter your selection")
    print("Thank you for using this program")

main()

def degrees(fahrenheit,celsius):#temperature subprogram
    fahrenheit = int(input("Enter temperature in fahrenheit"))
    celsius = (5/9)*(fahrenheit) - 32
    print(fahrenheit , " degrees = " , celsius , " degrees celsius.")


def meters(feet,meters):#distance subprogram
    feet = int(input("Enter measurement in feet"))
    meter = 0.305 * feet
    print(feet , " feet = " , meter , " meters.")

The error appears for lines 13 and 15, the lines calling the other modules. From reading other posts, they say that using parentheses instead of * for multiplication can be the cause, but I don't see where that would be the case.

0

1 Answer 1

2

You have a name conflict: degrees and meters were defined as floats and then as functions. The float names are called instead of the functions which are defined at some later point in your module.

floats are not callable


You can resolve this by changing the name of your variables to something different. And moving the function main to the bottom of your module. In this way, variable names are distinct from function names, and the functions are already defined by the time you need to call them in your main.

Sign up to request clarification or add additional context in comments.

1 Comment

There's also unused parameters in both functions, that are later assigned in the function body

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.