Python Forum
Function arguments help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function arguments help
#1
I've created a BMI Index in python for a class I'm in and I'm trying to get it to do a few things without any luck. What I want it to do is just ask for the input (height and weight) then print the "BMI Index" with the name and results below then add the next user and do the same. For some reason I can only get it to print each line after I enter it. Not sure what I'm supposed to do as I'm still pretty new to this. If anyone could provide some insight it would greatly be appreciated. Thanks in advance.


##########What it's doing##########

Welcome to the BMI Index Calculator.
Please begin by entering your name, or 0 to quit: John
John's BMI Profile
.................
Please enter height in inches: ##
Height: ## "Shouldn't print yet
Please enter weight in pounds: ###
Weight: ### lbs Shouldn't print yet
BMI Index: ##.#
Please begin by entering your name, or 0 to quit: Jane
Jane's BMI Profile
.................
Please enter height in inches:


##########What I want it to do##########

Welcome to the BMI Index Calculator.
Please begin by entering your name, or 0 to quit: John
Please enter height in inches: ##
Please enter weight in pounds: ###

John's BMI Profile
............................
Height: ###"
Weight: ### lbs
BMI Index:##.#

Please begin by entering the your name, or 0 to quit: Jane
Please enter height in inches: ##
Please enter weight in pounds: ###

Jane's BMI Profile
............................
Height: ###"
Weight: ### lbs
BMI Index:##.#

Please begin by entering the your name, or 0 to quit: 0

Exiting Program...

def h():
    height = int(input("Please enter height in inches: "))
    return height


def w():
    weight = int(input("Please enter weight in pounds: "))
    return weight


def bmi(height, weight):
    total = float((weight * 703) / (height * height))
    return total


def printbmi(name):
    print(name + "'s BMI Profile\n .................")
    height = h()
    print("Height:", str(height), "\"")
    weight = w()
    print("Weight:", str(weight), "lbs")
    print("BMI Index:{0}".format(str(float(round(bmi(height, weight), 1)))))

def main(name):
    printbmi(name)


print("BMI Index Calculator.")

while True:
    name = input("Please begin by entering the your name, or 0 to quit:")
    if name == "0":
        print("Exiting Program...")
        break
    else:
        main(name)
Reply
#2
look at your printbmi function and the order in which you collect user input and print it/result
Reply
#3
I got it Fixed... Thanks anyways for looking
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use value in dictionary as arguments in function gabejohnsonny21 6 3,832 Apr-22-2020, 04:53 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020