Yahoo India Web Search

Search results

  1. Oct 30, 2015 · The program calculates a person's BMI from the weight and height supplied using the user's input. However, after I enter 'metric' or 'imperial' and press enter, the program closes. The first three ...

  2. Feb 8, 2022 · The problem lies in your _get_user_info function. I added the missing entries in the function below. Also, as Tim Roberts said, you don't need to wrap input with str. input function returns a string in python 3.

  3. Feb 16, 2021 · I want to create a BMI calculator program with Tkinter but I'm stuck at calculation procedure I use StringVar() to keep user data to calculate but I don't know how to calculate this my code : from

  4. Oct 27, 2019 · import sys def bmi (height,weight): return height/weight**2 #if the script has been given 2 arguments, he continues, if not(=else) he print a message if len(sys.argv) == 3: #The first argument should be the height and the second one should be the weight height=float(sys.argv[1]) # argv[1] is a string and should be converted to float weight=int ...

  5. Nov 20, 2020 · Yes, there were several mistakes in your code as jaychandra mentioned. This is my solution to it. (round(BMI, 2) simply means the program will round off your value to 2 decimal places (as in your example, where it would print 31.80)

  6. Ok, there's a lot to be improved here. There's no validation on the gender input, so an unrecognised value could be entered, although this does seem to be handled in the final else case, where only the BMI, with no explanation, is printed.

  7. Nov 25, 2020 · There are 100 cm in one m; to convert from cm to m, divide by 100. # Write your BMI calculation loop here. for names in person_data: weight = person[1] height = person[2] % 100. bmi = weight % height**2. person.append(bmi) # Inside the loop print out each value for the bmi. print(bmi)

  8. Nov 23, 2020 · That's because in python your indentation determines the scope of what code gets run. whether the number is 1,2, or 3, the final 'print(f'Your BMI is {bmi}')' statement is still run. To prevent this youll have to move the scope of the print statement under the nested if statement, give me one moment and I will edit my answer to include this change

  9. Oct 29, 2012 · Hi, Im having troubles getting strings to turn into floats. Im trying to get my entry texts to turn the input into a float so i can calculate the bmi. from Tkinter import * import tkMessageBox cl...

  10. Nov 19, 2019 · In your original code the height and weight variables exist only within the scope of the bmi function while your last print statement is outside the scope of said function. A simple fix would be to put the last print before the return like so: