A command-line tool to help you decide what to eat today! This program randomly selects an appetizer, main course, and dessert from a variety of options and displays them in a visually appealing format. Perfect for those indecisive moments when you’re unsure what to eat.
- Randomized Meal Selection: The tool picks a random appetizer, main course, and dessert from predefined lists, offering a unique combination each time.
- Calorie-Based Selection: The user specifies a desired daily calorie intake, and the tool will select meals with a total calorie count that is less than or equal to the user’s input.
- Minimum Calorie Notification: If the user enters a calorie value that is too low, the tool notifies them of the minimum required calorie amount to generate a meal.
- Colorful Output: Using the
coloramalibrary, the output is formatted with color, making the meal suggestion visually appealing. - Cross-Platform Compatibility: Works on Windows, Mac, and Linux, thanks to
colorama.
========Today's Meal Suggestion========
Appetizer: Garlic Bread - 150 calories
Main Course: Sushi - 300 calories
Dessert: Ice Cream - 250 calories
Total Calories: 700
=======================================
Enjoy your meal!
- Python 3.6 or above
coloramalibrary
-
Clone the Repository (optional if you want to customize or save locally):
git clone <repository_url> cd meal-selector-cli
-
Install
colorama: Install the color library that enables the styled command-line output:pip install colorama
To run the program, simply execute the script from your terminal:
python meal_selector.pyEach time you run it, the program will generate a new meal suggestion based on your calorie intake.
The program uses the following components:
-
Imports and Initialization:
randomfor selecting random items.coloramafor color formatting in the command-line output. Theinit(autoreset=True)function ensures that styles reset automatically after each print statement, making it platform-compatible.
-
Data:
- Three lists (
appetizers,main_courses, anddesserts) store different meal options, each with a corresponding calorie count. - The minimum possible calorie intake is calculated from the lowest-calorie items in each category.
- Three lists (
-
pick_meal()Function:- A simple function that randomly picks an item from each list and checks whether the total calories are within the user's specified limit.
-
Error Handling:
- If the user enters a calorie count that is too low, the tool will notify them and ask for a new input.
-
Displaying the Output:
- The program prints each part of the meal (appetizer, main course, dessert) with labels, calories, and total calories, formatted for a visually engaging experience.
Feel free to modify the lists in the code to include your favorite dishes or additional meal options. Simply add more strings to the appetizers, main_courses, and desserts lists to personalize the tool.
Example:
# Adding items to the main_courses list
main_courses = ["Spaghetti Bolognese", "Grilled Chicken", "Vegetable Stir Fry", "Sushi", "Fried Rice", "Paneer Tikka"]-
Color Not Displaying:
- Make sure the
coloramalibrary is installed. You can check by running:pip show colorama
- If the problem persists, try using a different terminal or command-line tool.
- Make sure the
-
Adding More Items:
- Ensure each item is a string and separated by a comma in the list.
Thanks to the Python community for their continuous support, and to the developers of colorama for providing an easy-to-use library for command-line color formatting.