please do these five question which due by Sunday 11;59pm

1 answer below »
please do these five question which due by Sunday 11;59pm
Answered Same DayMar 27, 2021

Answer To: please do these five question which due by Sunday 11;59pm

Kshitij answered on Mar 30 2021
134 Votes
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"def cookFast(dishname,time):\n",
" \n",
" apiurl = \"https://api.spoonacular.com/recipes/search\"\
n",
" key = \"/?apiKey=025e964a69c642328d5c844399444b20\"\n",
" dishquery = \"&query=\"+ dishname\n",
" \n",
" url = apiurl + key + dishquery\n",
" r = requests.get(url)\n",
" \n",
" df = r.json()\n",
" l = []\n",
" \n",
" for item in df['results']:\n",
" if item['readyInMinutes']< time and item['servings']>=4:\n",
" l.append(item['title'])\n",
" return l"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Spaghetti Carbonara', 'Copycat Panera Macaroni and Cheese']\n"
]
}
],
"source": [
"print (cookFast(\"pasta\", 30))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Croque Monsieur Ham and Cheese Sandwich', 'Turkey Salad Sandwich', 'Sloppy Joes', 'Bruschetta Meatball Subs']\n"
]
}
],
"source": [
"print (cookFast(\"sandwich\", 35))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def nutrients(name,minv,maxv):\n",
" \n",
" apiurl='https://api.spoonacular.com/recipes/findByNutrients'\n",
" key=\"/?apiKey=025e964a69c642328d5c844399444b20\"\n",
" \n",
" name=name.replace(' ','')\n",
" namequery='&min' + name + \"=\" + str(minv) + '&max' + name + \"=\" + str(maxv)\n",
" url = apiurl + key + namequery\n",
" \n",
" request = requests.get(url)\n",
" df = request.json()\n",
" c=[]\n",
" \n",
" for item in df:\n",
" c.append(item['title'])\n",
" return c"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Baked Lasagne']\n"
]
}
],
"source": [
"print(nutrients(\"Calcium\", 1500, 1510))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"source": [
"print(nutrients(\"VitaminB12\", 200, 240))"
]
},
{
"cell_type": "code",
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here