├── LICENSE.md └── initial /LICENSE.md: -------------------------------------------------------------------------------- 1 | // free // 2 | -------------------------------------------------------------------------------- /initial: -------------------------------------------------------------------------------- 1 | # Define a function to add a food item and its calories to the log 2 | def add_food(log): 3 | food_item = input("Enter the food item: ") 4 | calories = int(input(f"Enter the calories for {food_item}: ")) 5 | log[food_item] = calories 6 | print(f"Added {food_item} with {calories} calories.\n") 7 | 8 | # Define a function to display the total calories for the day 9 | def view_total_calories(log): 10 | total_calories = sum(log.values()) 11 | print(f"Total calories for today: {total_calories}\n") 12 | 13 | # Define a function to display all food items and their calories 14 | def view_food_log(log): 15 | if log: 16 | print("Today's food log:") 17 | for food_item, calories in log.items(): 18 | print(f"{food_item}: {calories} calories") 19 | else: 20 | print("No food items logged yet.") 21 | print() 22 | --------------------------------------------------------------------------------