Untitled
unknown
plain_text
a year ago
1.7 kB
1
Indexable
Never
# Zero Hunger Application # Initialize variables to track food consumption total_calories = 0 total_protein = 0 total_carbs = 0 total_fat = 0 # Function to add a food item def add_food_item(): global total_calories, total_protein, total_carbs, total_fat name = input("Enter the name of the food item: ") calories = float(input("Enter the calories in the food item: ")) protein = float(input("Enter the protein content (g) in the food item: ")) carbs = float(input("Enter the carbohydrate content (g) in the food item: ")) fat = float(input("Enter the fat content (g) in the food item: ")) total_calories += calories total_protein += protein total_carbs += carbs total_fat += fat print(f"{name} added to your daily consumption.") # Function to display daily food consumption def display_consumption(): print("\n--- Daily Food Consumption ---") print(f"Total Calories: {total_calories} kcal") print(f"Total Protein: {total_protein} g") print(f"Total Carbohydrates: {total_carbs} g") print(f"Total Fat: {total_fat} g") # Main menu while True: print("\n--- Zero Hunger Application ---") print("1. Add Food Item") print("2. Display Daily Consumption") print("3. Exit") choice = input("Enter your choice: ") if choice == '1': add_food_item() elif choice == '2': display_consumption() elif choice == '3': print("Exiting the application. Thank you for contributing to Zero Hunger!") break else: print("Invalid choice. Please enter a valid option.")