Hello All,
I need help. Can someone tell me why I am not getting any results. Look like I am losing the variables values.
Here is my code.
# Global constant for Calories
CALORIES_FROM_FAT = 9
CALORIES_FROM_CARBS = 4
# main module
# Get grams fat
def main():
gramsFat = gramsCarbs = caloriesFat = caloriesCarbs = 0.0
getFat(gramsFat)
setFat(gramsFat,CALORIES_FROM_FAT)
getCarbs(gramsCarbs)
setCarbs(gramsCarbs, CALORIES_FROM_CARBS)
showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs)
# The getFat module gets weight and stores it
# in the inputFat reference variable.
def getFat(gramsFat):
gramsFat = float(input('Enter the number of fat grams consumed: '))
def setFat(gramsFat,CALORIES_FROM_FAT):
caloriesFat = float(gramsFat * CALORIES_FROM_FAT)
def getCarbs(gramsCarbs):
gramsCarbs = float(input("Enter carbohydrate grams consumed: "))
def setCarbs(gramsCarbs, CALORIES_FROM_CARBS):
caloriesCarbs = gramsCarbs * CALORIES_FROM_CARBS
# ------------------------------------------------------------------------
# The showCarbs function accepts the number of grams of fat and of carbs,
# as well as the calories from fat and from carbs, as arguments
# and displays the resulting calories
def showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs):
print("Grams of Fat: ", gramsFat)
print("Result calories: ", caloriesFat)
print("Grams of Carbs: ", gramsCarbs)
print("Result calories: ", caloriesCarbs)
# Call Main Function
main()
I need help. Can someone tell me why I am not getting any results. Look like I am losing the variables values.
Here is my code.
# Global constant for Calories
CALORIES_FROM_FAT = 9
CALORIES_FROM_CARBS = 4
# main module
# Get grams fat
def main():
gramsFat = gramsCarbs = caloriesFat = caloriesCarbs = 0.0
getFat(gramsFat)
setFat(gramsFat,CALORIES_FROM_FAT)
getCarbs(gramsCarbs)
setCarbs(gramsCarbs, CALORIES_FROM_CARBS)
showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs)
# The getFat module gets weight and stores it
# in the inputFat reference variable.
def getFat(gramsFat):
gramsFat = float(input('Enter the number of fat grams consumed: '))
def setFat(gramsFat,CALORIES_FROM_FAT):
caloriesFat = float(gramsFat * CALORIES_FROM_FAT)
def getCarbs(gramsCarbs):
gramsCarbs = float(input("Enter carbohydrate grams consumed: "))
def setCarbs(gramsCarbs, CALORIES_FROM_CARBS):
caloriesCarbs = gramsCarbs * CALORIES_FROM_CARBS
# ------------------------------------------------------------------------
# The showCarbs function accepts the number of grams of fat and of carbs,
# as well as the calories from fat and from carbs, as arguments
# and displays the resulting calories
def showCarbs(gramsFat, gramsCarbs, caloriesFat, caloriesCarbs):
print("Grams of Fat: ", gramsFat)
print("Result calories: ", caloriesFat)
print("Grams of Carbs: ", gramsCarbs)
print("Result calories: ", caloriesCarbs)
# Call Main Function
main()