Hello all! Hope to be a very active nad productive member here as I learn. Currently in a python class and have a problem to solve. Not quite sure where my mistake is.... I am to put the inputs in the main function pass to the processing function and call processing function in the main. Here is where I am....

# Define main and inputs ^.^
def main():
    #call inputs
    inputs()
    #get the math
    hw_to_bmi(weight, height)


def inputs():
    weight = float(input('Enter weight in pounds: '))
    height = float(input('Enter height in inches: '))


def hw_to_bmi(weight, height):
    bmi = (weight / (height * height)) * 703
    print('Your BMI is .2f' % bmi)


main ()

Recommended Answers

All 2 Replies

Hi some problems with function inputs(),you need to retun values out and assign it to one or two variabels in main.
This should do it.

def inputs():
    '''Get input from user'''
    weight = float(input('Enter weight in pounds: '))
    height = float(input('Enter height in inches: '))
    return weight, height

def hw_to_bmi(weight, height):
    '''Calculate bmi'''
    bmi = (weight / (height * height)) * 703
    print('Your BMI is %.2f' % bmi)

def main():
    weight,height = inputs()
    hw_to_bmi(weight,height)
    print(hw_to_bmi.__doc__)
    help(inputs)

main()

Thanks for the help! So my main issue was forgetting to return the weight and height from inputs and also forgetting to print hw_to_bmi and also not calling weight and height with inputs.

I thank you again for the help! Sure is a learning process!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.