|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "e51b3661-7552-4625-a1a2-f8a53cdbda54", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Diet Recommendation System (Basic Version)" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "markdown", |
| 13 | + "id": "5918a4e1-c0f0-46b1-8b63-6e25e0816620", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "# Install necessary libraries" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "code", |
| 21 | + "execution_count": 7, |
| 22 | + "id": "bfd7cc27-4a1d-4aac-81fe-eac8f21df9ef", |
| 23 | + "metadata": {}, |
| 24 | + "outputs": [ |
| 25 | + { |
| 26 | + "name": "stdout", |
| 27 | + "output_type": "stream", |
| 28 | + "text": [ |
| 29 | + "Requirement already satisfied: pandas in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (2.2.2)\n", |
| 30 | + "Requirement already satisfied: numpy>=1.26.0 in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (from pandas) (1.26.4)\n", |
| 31 | + "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (from pandas) (2.9.0.post0)\n", |
| 32 | + "Requirement already satisfied: pytz>=2020.1 in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (from pandas) (2024.1)\n", |
| 33 | + "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (from pandas) (2023.3)\n", |
| 34 | + "Requirement already satisfied: six>=1.5 in c:\\users\\rameswar bisoyi\\anaconda3\\lib\\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\n" |
| 35 | + ] |
| 36 | + } |
| 37 | + ], |
| 38 | + "source": [ |
| 39 | + "!pip install pandas\n", |
| 40 | + "\n", |
| 41 | + "import pandas as pd" |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "markdown", |
| 46 | + "id": "495edbf2-870d-403b-a35c-504f505630cd", |
| 47 | + "metadata": {}, |
| 48 | + "source": [ |
| 49 | + "# Function to get basic diet recommendations" |
| 50 | + ] |
| 51 | + }, |
| 52 | + { |
| 53 | + "cell_type": "code", |
| 54 | + "execution_count": 9, |
| 55 | + "id": "b21d9cf3-df1a-4376-90f5-9596a0f31d18", |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "def get_diet_recommendation(age, weight, height, activity_level, goal):\n", |
| 60 | + " # Basic calculations\n", |
| 61 | + " bmi = weight / (height / 100) ** 2\n", |
| 62 | + " calories_needed = 0\n", |
| 63 | + "\n", |
| 64 | + " # Determine calorie needs based on activity level\n", |
| 65 | + " if activity_level == 'low':\n", |
| 66 | + " calories_needed = 2000 if goal == 'maintain' else (1800 if goal == 'lose' else 2200)\n", |
| 67 | + " elif activity_level == 'medium':\n", |
| 68 | + " calories_needed = 2200 if goal == 'maintain' else (2000 if goal == 'lose' else 2400)\n", |
| 69 | + " elif activity_level == 'high':\n", |
| 70 | + " calories_needed = 2500 if goal == 'maintain' else (2300 if goal == 'lose' else 2700)\n", |
| 71 | + "\n", |
| 72 | + " # Basic diet recommendation\n", |
| 73 | + " diet_plan = {\n", |
| 74 | + " 'Breakfast': f'Oats with fruits and nuts - {calories_needed * 0.3:.0f} cal',\n", |
| 75 | + " 'Lunch': f'Grilled chicken with vegetables - {calories_needed * 0.4:.0f} cal',\n", |
| 76 | + " 'Dinner': f'Salad with chickpeas and avocado - {calories_needed * 0.3:.0f} cal'\n", |
| 77 | + " }\n", |
| 78 | + "\n", |
| 79 | + " return {\n", |
| 80 | + " 'BMI': round(bmi, 2),\n", |
| 81 | + " 'Calories Needed': calories_needed,\n", |
| 82 | + " 'Diet Plan': diet_plan\n", |
| 83 | + " }\n" |
| 84 | + ] |
| 85 | + }, |
| 86 | + { |
| 87 | + "cell_type": "markdown", |
| 88 | + "id": "b1f6fce0-1de5-4f8a-a9ed-609a6ada2da3", |
| 89 | + "metadata": {}, |
| 90 | + "source": [ |
| 91 | + "# Input user information" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "code", |
| 96 | + "execution_count": 15, |
| 97 | + "id": "0c51a088-cf5b-45a6-ad3e-7260f3d7ca4a", |
| 98 | + "metadata": {}, |
| 99 | + "outputs": [ |
| 100 | + { |
| 101 | + "name": "stdout", |
| 102 | + "output_type": "stream", |
| 103 | + "text": [ |
| 104 | + "Enter age: 20\n", |
| 105 | + "Enter weight in kg: 59\n", |
| 106 | + "Enter height in cm: 172\n", |
| 107 | + "Enter activity level (low, medium, high): medium\n", |
| 108 | + "Enter your goal (maintain, lose, gain): gain\n" |
| 109 | + ] |
| 110 | + } |
| 111 | + ], |
| 112 | + "source": [ |
| 113 | + "age = int(input(\"Enter age: \"))\n", |
| 114 | + "weight = float(input(\"Enter weight in kg: \"))\n", |
| 115 | + "height = float(input(\"Enter height in cm: \"))\n", |
| 116 | + "activity_level = input(\"Enter activity level (low, medium, high): \").lower()\n", |
| 117 | + "goal = input(\"Enter your goal (maintain, lose, gain): \").lower()\n", |
| 118 | + "\n", |
| 119 | + "# Get diet recommendation\n", |
| 120 | + "recommendation = get_diet_recommendation(age, weight, height, activity_level, goal)" |
| 121 | + ] |
| 122 | + }, |
| 123 | + { |
| 124 | + "cell_type": "markdown", |
| 125 | + "id": "2c119676-3b1d-4929-ba0d-d3da08cf6297", |
| 126 | + "metadata": {}, |
| 127 | + "source": [ |
| 128 | + "# Display result" |
| 129 | + ] |
| 130 | + }, |
| 131 | + { |
| 132 | + "cell_type": "code", |
| 133 | + "execution_count": 18, |
| 134 | + "id": "ebeb1765-a75f-4e81-b882-ea76c1efde5f", |
| 135 | + "metadata": {}, |
| 136 | + "outputs": [ |
| 137 | + { |
| 138 | + "name": "stdout", |
| 139 | + "output_type": "stream", |
| 140 | + "text": [ |
| 141 | + "\n", |
| 142 | + "Your Diet Recommendation:\n", |
| 143 | + "BMI: 19.94\n", |
| 144 | + "Calories Needed: 2400\n", |
| 145 | + "Meal Plan:\n", |
| 146 | + "Breakfast: Oats with fruits and nuts - 720 cal\n", |
| 147 | + "Lunch: Grilled chicken with vegetables - 960 cal\n", |
| 148 | + "Dinner: Salad with chickpeas and avocado - 720 cal\n" |
| 149 | + ] |
| 150 | + } |
| 151 | + ], |
| 152 | + "source": [ |
| 153 | + "print(\"\\nYour Diet Recommendation:\")\n", |
| 154 | + "print(f\"BMI: {recommendation['BMI']}\")\n", |
| 155 | + "print(f\"Calories Needed: {recommendation['Calories Needed']}\")\n", |
| 156 | + "print(\"Meal Plan:\")\n", |
| 157 | + "for meal, details in recommendation['Diet Plan'].items():\n", |
| 158 | + " print(f\"{meal}: {details}\")\n" |
| 159 | + ] |
| 160 | + }, |
| 161 | + { |
| 162 | + "cell_type": "code", |
| 163 | + "execution_count": null, |
| 164 | + "id": "e2208375-2574-4696-9320-601c78fa3ba7", |
| 165 | + "metadata": {}, |
| 166 | + "outputs": [], |
| 167 | + "source": [] |
| 168 | + } |
| 169 | + ], |
| 170 | + "metadata": { |
| 171 | + "kernelspec": { |
| 172 | + "display_name": "base", |
| 173 | + "language": "python", |
| 174 | + "name": "python3" |
| 175 | + }, |
| 176 | + "language_info": { |
| 177 | + "codemirror_mode": { |
| 178 | + "name": "ipython", |
| 179 | + "version": 3 |
| 180 | + }, |
| 181 | + "file_extension": ".py", |
| 182 | + "mimetype": "text/x-python", |
| 183 | + "name": "python", |
| 184 | + "nbconvert_exporter": "python", |
| 185 | + "pygments_lexer": "ipython3", |
| 186 | + "version": "3.12.4" |
| 187 | + } |
| 188 | + }, |
| 189 | + "nbformat": 4, |
| 190 | + "nbformat_minor": 5 |
| 191 | +} |
0 commit comments