Arnie R.
asked 07/23/18Question about Python functions
name3 = "Mary"
weight_kg3 = 160
def bmi_calculator(name, height_m, weight_kg):
bmi = weight_kg / (height_m ** 2)
print("bmi: ")
1 Expert Answer

Matthew B. answered 11/13/19
Founder, CEO, and Lead Developer: Apteryx Labs | Stanford, 2015
The variables you defined:
...in turn are arguments to the function you defined:
It's better practice to return the data from the function and THEN print it, instead of printing from within the function itself:
This is called 'code encapsulation', and is one of the things that makes object oriented programming (the norm nowadays) so powerful.
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Avishkar T.
Hy Arnie R. , Python function is a set of statements that take inputs, do some specific computation and produces output. It may or may not return value. In your question you have defined a function named bmi_calculator which takes three parameters name, height_m and weight_kg. Also you have declared height_m3 , name3 and weight_kg3 with the values 2.5, Mary and 260 respectively. You can call the function bmf with the syntax bmi( height_m3,name3,weight_kg3) weight_kg / (height_m ** 2) is performed and then assigned to bmi. which is then printed out. I hope you understood. Let me know if you have any questions.11/08/19