0

I cant figure out what arguements to use or really even what arguements are.

#Template for Program 2
#The keyword "pass" is a placeholder that does nothing
#Move each line of original code into the appropriate module
#Add arguments to calcBMI() and displayResults() as needed

#original code -- not in modules yet
#cut and paste into appropriate modules below


#revised code broken into modules
#delete "pass" once you add code to a module
#don't forget to indent
def main():
    print("Body Mass Index (BMI) Program")
    print()
    weight = float(input("Enter your weight in pounds: "))
    height = float(input("Enter your height in inches: "))
    calcBMI()

def calcBMI():
    bmi = (weight * 703)/(height * height)
    displayResults()


def displayResults(bmi):
    print()
    print("Your BMI is:", bmi)

#Call the main function to get things started

main()

2
Contributors
2
Replies
31
Views
2 Years
Discussion Span
Last Post by Julie_2
2

Greetings:

First and foremost, I warmly applaud your efforts to learn Python.

That being said, arguments in Python are parameters(or local variables) that are passed(or given) to a function to work with.

Your calcBMI function is currently not set-up to receive any parameters. Also, it's a better programming practice to let your main function execute all of the functions in your program. Here's a fix:

def main():
    print("Body Mass Index (BMI) Program")
    print()
    weight = float(input("Enter your weight in pounds: "))
    height = float(input("Enter your height in inches: "))
    bmi = calcBMI(weight, height)
    displayResults(bmi)

def calcBMI(weight, height):
    return (weight * 703) / (height * height)

def displayResults(bmi):
    print()
    print("Your BMI is:", bmi)

if __name__ == "__main__":
    main()
Votes + Comments
Nice answer :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.