Addition of arguments to Tutorial 18

0 Tee Yong Ng · July 1, 2015
Hello, for the health calculator, using the formula, if I want to add a range to determine if a person is healthy or not:

for eg:

def health_calculator(age, calories_intake, exercise_time):
health_indicator = (age*2) + (calories_intake - 2000) + (exercise_time)
print(health_indicator)

Guest_Data = [25, 3000, 30]

health_calculator(*Guest_Data)

if health_indicator() > 1000:
print('you are healthy')

---

I got the number out for the health_indicator, but I cannot print out the 'you are healthy' part.

Any help/suggestions??

Post a Reply

Replies

Oldest  Newest  Rating
+1 Bucky Roberts · July 1, 2015
Your health_calculator function needs a return statement, that way it can calculate the result and you can compare it against 1000...
# this function needs to return some value (give back a result)
def health_calculator(age, calories_intake, exercise_time):
    health_indicator = (age*2) + (calories_intake - 2000) + (exercise_time)
    print(health_indicator)
    return health_indicator

if health_calculator(25, 3000, 30) > 1000:
    print('you are healthy')
+1 Tee Yong Ng · July 2, 2015
oh yeah it works thanks!
0 Ebenezer Popoola · July 7, 2015
@Tee , also take note of your indentation as your print statement was not properly indented. Little things like that can cause problems for python.
  • 1

Python

106,940 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator