pub-3785248829033902 | Python: Input method and your BMI | - Big data with Python

| Python: Input method and your BMI |

If the input function is called, the program flow will be stopped until the user has given an input and has ended the input with the return key.



The text of the optional parameter, i.e. the prompt, will be printed on the screen. The input of the user will be interpreted. If the user e.g. puts in an integer value, the input function returns this integer value. If the user on the other hand inputs a list, the function will return a list.

The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of input statement in Python:



Æ’ python command

weight = float(input('Enter your Weight: '))
height = float(input('Enter your Height: '))
print('Your BMI is %d' % (weight/(height**2)*10000))

output

Enter your Weight: 83.5
Enter your Height: 187.4
Your BMI is 23  

Previous
Next Post »