From 54c75e9b2d5230ae8fb18ced39d07bcbd369e990 Mon Sep 17 00:00:00 2001 From: lakshmi-warrier Date: Sun, 10 Jan 2021 20:50:59 +0530 Subject: [PATCH] Challenge completed: extra-ongoing --- Python-ifed.ipynb | 858 +++++++++++++++++- __pycache__/ability.cpython-38.pyc | Bin 0 -> 474 bytes __pycache__/nearest_square.cpython-38.pyc | Bin 0 -> 331 bytes __pycache__/pokedex.cpython-38.pyc | Bin 0 -> 1933 bytes ...test_abilities.cpython-38-pytest-6.2.1.pyc | Bin 0 -> 1986 bytes ...nearest_square.cpython-38-pytest-6.2.1.pyc | Bin 0 -> 2032 bytes ability.py | 11 + nearest_square.py | 8 + pokedex.py | 91 ++ pokedex_design.py | 39 + step_4.py | 101 +++ test_nearest_square.py | 3 +- 12 files changed, 1068 insertions(+), 43 deletions(-) create mode 100644 __pycache__/ability.cpython-38.pyc create mode 100644 __pycache__/nearest_square.cpython-38.pyc create mode 100644 __pycache__/pokedex.cpython-38.pyc create mode 100644 __pycache__/test_abilities.cpython-38-pytest-6.2.1.pyc create mode 100644 __pycache__/test_nearest_square.cpython-38-pytest-6.2.1.pyc create mode 100644 ability.py create mode 100644 nearest_square.py create mode 100644 pokedex.py create mode 100644 pokedex_design.py create mode 100644 step_4.py diff --git a/Python-ifed.ipynb b/Python-ifed.ipynb index ee9444d..0d58e79 100644 --- a/Python-ifed.ipynb +++ b/Python-ifed.ipynb @@ -62,15 +62,15 @@ "### Describe what each of the following means\n", "\n", "#### Production\n", - "(Insert answer here)\n", + "Production code runs on production servers so that it is the best version known to the public. It meets expectations in reliability, efficiency, etc.\n", "#### Clean \n", - "(Insert answer here)\n", + "Clean code is a concise, simple and readable code\n", "#### Modular\n", - "(Insert answer here)\n", + "Code that is logically broken up into functions and modules so that is more organized, efficient, and reusable.\n", "#### Module\n", - "(Insert answer here)\n", + "A file of code that can be imported to other files, so that the code can be reused\n", "#### Refactoring code\n", - "(Insert answer here)" + "improving the existing code without adding new functionality and the external features remain the same." ] }, { @@ -93,9 +93,214 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Seasoncitydateteam 1team 2toss winnertoss decisionresultdl appliedwinnerwin by runswin by wicketsplayer of matchvenueumpire 1umpire 2
id
1IPL-2017Hyderabad05-04-2017Sunrisers HyderabadRoyal Challengers BangaloreRoyal Challengers Bangalorefieldnormal0Sunrisers Hyderabad350Yuvraj SinghRajiv Gandhi International Stadium, UppalAY DandekarNJ Llong
2IPL-2017Pune06-04-2017Mumbai IndiansRising Pune SupergiantRising Pune Supergiantfieldnormal0Rising Pune Supergiant07SPD SmithMaharashtra Cricket Association StadiumA Nand KishoreS Ravi
3IPL-2017Rajkot07-04-2017Gujarat LionsKolkata Knight RidersKolkata Knight Ridersfieldnormal0Kolkata Knight Riders010CA LynnSaurashtra Cricket Association StadiumNitin MenonCK Nandan
4IPL-2017Indore08-04-2017Rising Pune SupergiantKings XI PunjabKings XI Punjabfieldnormal0Kings XI Punjab06GJ MaxwellHolkar Cricket StadiumAK ChaudharyC Shamshuddin
5IPL-2017Bangalore08-04-2017Royal Challengers BangaloreDelhi DaredevilsRoyal Challengers Bangalorebatnormal0Royal Challengers Bangalore150KM JadhavM Chinnaswamy StadiumNaNNaN
\n", + "
" + ], + "text/plain": [ + " Season city date team 1 \\\n", + "id \n", + "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n", + "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n", + "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n", + "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n", + "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n", + "\n", + " team 2 toss winner toss decision \\\n", + "id \n", + "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n", + "2 Rising Pune Supergiant Rising Pune Supergiant field \n", + "3 Kolkata Knight Riders Kolkata Knight Riders field \n", + "4 Kings XI Punjab Kings XI Punjab field \n", + "5 Delhi Daredevils Royal Challengers Bangalore bat \n", + "\n", + " result dl applied winner win by runs \\\n", + "id \n", + "1 normal 0 Sunrisers Hyderabad 35 \n", + "2 normal 0 Rising Pune Supergiant 0 \n", + "3 normal 0 Kolkata Knight Riders 0 \n", + "4 normal 0 Kings XI Punjab 0 \n", + "5 normal 0 Royal Challengers Bangalore 15 \n", + "\n", + " win by wickets player of match venue \\\n", + "id \n", + "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n", + "2 7 SPD Smith Maharashtra Cricket Association Stadium \n", + "3 10 CA Lynn Saurashtra Cricket Association Stadium \n", + "4 6 GJ Maxwell Holkar Cricket Stadium \n", + "5 0 KM Jadhav M Chinnaswamy Stadium \n", + "\n", + " umpire 1 umpire 2 \n", + "id \n", + "1 AY Dandekar NJ Llong \n", + "2 A Nand Kishore S Ravi \n", + "3 Nitin Menon CK Nandan \n", + "4 AK Chaudhary C Shamshuddin \n", + "5 NaN NaN " + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import pandas as pd\n", "df = pd.read_csv('matches.csv', sep=',')\n", @@ -113,9 +318,214 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Seasoncitydateteam_1team_2toss_winnertoss decisionresultdl_appliedwinnerwin_by_runswin_by_wicketsplayer_of_matchvenueumpire_1umpire_2
id
1IPL-2017Hyderabad05-04-2017Sunrisers HyderabadRoyal Challengers BangaloreRoyal Challengers Bangalorefieldnormal0Sunrisers Hyderabad350Yuvraj SinghRajiv Gandhi International Stadium, UppalAY DandekarNJ Llong
2IPL-2017Pune06-04-2017Mumbai IndiansRising Pune SupergiantRising Pune Supergiantfieldnormal0Rising Pune Supergiant07SPD SmithMaharashtra Cricket Association StadiumA Nand KishoreS Ravi
3IPL-2017Rajkot07-04-2017Gujarat LionsKolkata Knight RidersKolkata Knight Ridersfieldnormal0Kolkata Knight Riders010CA LynnSaurashtra Cricket Association StadiumNitin MenonCK Nandan
4IPL-2017Indore08-04-2017Rising Pune SupergiantKings XI PunjabKings XI Punjabfieldnormal0Kings XI Punjab06GJ MaxwellHolkar Cricket StadiumAK ChaudharyC Shamshuddin
5IPL-2017Bangalore08-04-2017Royal Challengers BangaloreDelhi DaredevilsRoyal Challengers Bangalorebatnormal0Royal Challengers Bangalore150KM JadhavM Chinnaswamy StadiumNaNNaN
\n", + "
" + ], + "text/plain": [ + " Season city date team_1 \\\n", + "id \n", + "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n", + "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n", + "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n", + "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n", + "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n", + "\n", + " team_2 toss_winner toss decision \\\n", + "id \n", + "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n", + "2 Rising Pune Supergiant Rising Pune Supergiant field \n", + "3 Kolkata Knight Riders Kolkata Knight Riders field \n", + "4 Kings XI Punjab Kings XI Punjab field \n", + "5 Delhi Daredevils Royal Challengers Bangalore bat \n", + "\n", + " result dl_applied winner win_by_runs \\\n", + "id \n", + "1 normal 0 Sunrisers Hyderabad 35 \n", + "2 normal 0 Rising Pune Supergiant 0 \n", + "3 normal 0 Kolkata Knight Riders 0 \n", + "4 normal 0 Kings XI Punjab 0 \n", + "5 normal 0 Royal Challengers Bangalore 15 \n", + "\n", + " win_by_wickets player_of_match venue \\\n", + "id \n", + "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n", + "2 7 SPD Smith Maharashtra Cricket Association Stadium \n", + "3 10 CA Lynn Saurashtra Cricket Association Stadium \n", + "4 6 GJ Maxwell Holkar Cricket Stadium \n", + "5 0 KM Jadhav M Chinnaswamy Stadium \n", + "\n", + " umpire_1 umpire_2 \n", + "id \n", + "1 AY Dandekar NJ Llong \n", + "2 A Nand Kishore S Ravi \n", + "3 Nitin Menon CK Nandan \n", + "4 AK Chaudhary C Shamshuddin \n", + "5 NaN NaN " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "new_df = df.rename(columns={'team 1': 'team_1',\n", " 'team 2': 'team_2',\n", @@ -139,9 +549,214 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Seasoncitydateteam_1team 2toss_winnertoss_decisionresultdl_appliedwinnerwin_by_runswin by wicketsplayer of matchvenueumpire 1umpire 2
id
1IPL-2017Hyderabad05-04-2017Sunrisers HyderabadRoyal Challengers BangaloreRoyal Challengers Bangalorefieldnormal0Sunrisers Hyderabad350Yuvraj SinghRajiv Gandhi International Stadium, UppalAY DandekarNJ Llong
2IPL-2017Pune06-04-2017Mumbai IndiansRising Pune SupergiantRising Pune Supergiantfieldnormal0Rising Pune Supergiant07SPD SmithMaharashtra Cricket Association StadiumA Nand KishoreS Ravi
3IPL-2017Rajkot07-04-2017Gujarat LionsKolkata Knight RidersKolkata Knight Ridersfieldnormal0Kolkata Knight Riders010CA LynnSaurashtra Cricket Association StadiumNitin MenonCK Nandan
4IPL-2017Indore08-04-2017Rising Pune SupergiantKings XI PunjabKings XI Punjabfieldnormal0Kings XI Punjab06GJ MaxwellHolkar Cricket StadiumAK ChaudharyC Shamshuddin
5IPL-2017Bangalore08-04-2017Royal Challengers BangaloreDelhi DaredevilsRoyal Challengers Bangalorebatnormal0Royal Challengers Bangalore150KM JadhavM Chinnaswamy StadiumNaNNaN
\n", + "
" + ], + "text/plain": [ + " Season city date team_1 \\\n", + "id \n", + "1 IPL-2017 Hyderabad 05-04-2017 Sunrisers Hyderabad \n", + "2 IPL-2017 Pune 06-04-2017 Mumbai Indians \n", + "3 IPL-2017 Rajkot 07-04-2017 Gujarat Lions \n", + "4 IPL-2017 Indore 08-04-2017 Rising Pune Supergiant \n", + "5 IPL-2017 Bangalore 08-04-2017 Royal Challengers Bangalore \n", + "\n", + " team 2 toss_winner toss_decision \\\n", + "id \n", + "1 Royal Challengers Bangalore Royal Challengers Bangalore field \n", + "2 Rising Pune Supergiant Rising Pune Supergiant field \n", + "3 Kolkata Knight Riders Kolkata Knight Riders field \n", + "4 Kings XI Punjab Kings XI Punjab field \n", + "5 Delhi Daredevils Royal Challengers Bangalore bat \n", + "\n", + " result dl_applied winner win_by_runs \\\n", + "id \n", + "1 normal 0 Sunrisers Hyderabad 35 \n", + "2 normal 0 Rising Pune Supergiant 0 \n", + "3 normal 0 Kolkata Knight Riders 0 \n", + "4 normal 0 Kings XI Punjab 0 \n", + "5 normal 0 Royal Challengers Bangalore 15 \n", + "\n", + " win by wickets player of match venue \\\n", + "id \n", + "1 0 Yuvraj Singh Rajiv Gandhi International Stadium, Uppal \n", + "2 7 SPD Smith Maharashtra Cricket Association Stadium \n", + "3 10 CA Lynn Saurashtra Cricket Association Stadium \n", + "4 6 GJ Maxwell Holkar Cricket Stadium \n", + "5 0 KM Jadhav M Chinnaswamy Stadium \n", + "\n", + " umpire 1 umpire 2 \n", + "id \n", + "1 AY Dandekar NJ Llong \n", + "2 A Nand Kishore S Ravi \n", + "3 Nitin Menon CK Nandan \n", + "4 AK Chaudhary C Shamshuddin \n", + "5 NaN NaN " + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "labels = list(df.columns)\n", "labels[0] = labels[0].replace(' ', '_')\n", @@ -167,11 +782,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Index(['Season', 'city', 'date', 'team 1', 'team 2', 'toss winner',\n", + " 'toss decision', 'result', 'dl applied', 'winner', 'win by runs',\n", + " 'win by wickets', 'player of match', 'venue', 'umpire 1', 'umpire 2'],\n", + " dtype='object')\n", + "Index(['Season', 'city', 'date', 'team_1', 'team 2', 'toss_winner',\n", + " 'toss_decision', 'result', 'dl_applied', 'winner', 'win_by_runs',\n", + " 'win by wickets', 'player of match', 'venue', 'umpire 1', 'umpire 2'],\n", + " dtype='object')\n" + ] + } + ], "source": [ - "# Insert your solution here" + "print(df.columns)\n", + "df.columns =[list(df.columns)[i].replace(' ', '_') if (i!=4 and i<11) else list(df.columns)[i] for i in range(16)]\n", + "#df.columns = labels + list(df.columns)[10:]\n", + "print(df.columns)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 3, 4, 5]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = [1,2,3,4,5]\n", + "a = [i for i in a if i!=2]\n", + "a" ] }, { @@ -208,7 +863,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -219,7 +874,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -233,9 +888,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 8.536158084869385 seconds\n" + ] + } + ], "source": [ "start = time.time()\n", "verified_elements = []\n", @@ -243,7 +907,7 @@ "for element in subset_elements:\n", " if element in all_elements:\n", " verified_elements.append(element)\n", - "\n", + " \n", "print(len(verified_elements))\n", "print('Duration: {} seconds'.format(time.time() - start))" ] @@ -257,11 +921,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 0.025506258010864258 seconds\n" + ] + } + ], "source": [ - "# Insert answer here\n", + "start = time.time()\n", + "verfied_elements = np.intersect1d(subset_elements,all_elements) \n", "\n", "print(len(verified_elements))\n", "print('Duration: {} seconds'.format(time.time() - start))" @@ -276,12 +950,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 0.007076740264892578 seconds\n" + ] + } + ], "source": [ + "start = time.time()\n", "# Insert answer here\n", + "subset_elements = set(subset_elements)\n", + "all_elements = set(all_elements)\n", "\n", + "verified_elements = subset_elements.intersection(all_elements)\n", "print(len(verified_elements))\n", "print('Duration: {} seconds'.format(time.time() - start))" ] @@ -330,9 +1017,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 93, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m============================= test session starts ==============================\u001b[0m\r\n", + "platform linux -- Python 3.8.5, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\r\n", + "rootdir: /home/lakshmi/my-Python-ifed-challenge\r\n", + "plugins: anyio-2.0.2\r\n", + "\u001b[1mcollecting ... \u001b[0m\u001b[1m\r", + "collected 4 items \u001b[0m\r\n", + "\r\n", + "test_nearest_square.py \u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m [100%]\u001b[0m\r\n", + "\r\n", + "\u001b[32m============================== \u001b[32m\u001b[1m4 passed\u001b[0m\u001b[32m in 0.01s\u001b[0m\u001b[32m ===============================\u001b[0m\r\n" + ] + } + ], "source": [ "! pytest test_nearest_square.py" ] @@ -386,11 +1090,28 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 90, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "eevee\n", + "normal\n" + ] + } + ], "source": [ - "# Insert your code here" + "import requests, json\n", + "\n", + "response = requests.get('https://pokeapi.co/api/v2/pokemon/eevee')\n", + "\n", + "name = response.json()['species']['name']\n", + "print(name)\n", + "\n", + "poke_type = response.json()['types'][0]['type']['name']\n", + "print(poke_type)" ] }, { @@ -404,11 +1125,37 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 91, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "fighting\n" + ] + } + ], "source": [ - "# Insert your code here" + "response = requests.get('https://pokeapi.co/api/v2/pokemon/eevee')\n", + "\n", + "'''\n", + "##Add a for loop here - for more than 1 type\n", + "'''\n", + "url = response.json()['types'][0]['type']['url']\n", + "\n", + "response= requests.get(url)\n", + "dam_rel = response.json()['damage_relations']\n", + "\n", + "#extracting every key with substring damage_from, except no_damage_from\n", + "damage_list = [value for key, value in dam_rel.items() if ('damage_from' in key and 'no' not in key)]\n", + "# damage_from is a list of lists\n", + "\n", + "for damage_from in damage_list:\n", + " #iterating through lists\n", + " for damage in damage_from:\n", + " #damage - dictionary\n", + " print(damage['name'])\n" ] }, { @@ -420,11 +1167,37 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 87, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Double damage from:\n", + "fighting\n", + "https://pokeapi.co/api/v2/type/2/\n", + "mankey\n", + "primeape\n", + "poliwrath\n", + "machop\n", + "machoke\n" + ] + } + ], "source": [ - "# Insert your code here" + "print(\"Double damage from:\")\n", + "double_dam_url = []\n", + "for dam in range(len(dam_rel['double_damage_from'])):\n", + " double_dam_url.append(dam_rel['double_damage_from'][dam]['url'])\n", + " print(dam_rel['double_damage_from'][dam]['name'])\n", + "print((double_dam_url[0]))\n", + "\n", + "for dam_url in double_dam_url:\n", + " response = requests.get(dam_url)\n", + " pokemon = response.json()['pokemon']\n", + " for ind in range(5):\n", + " print(pokemon[ind]['pokemon']['name'])" ] }, { @@ -438,7 +1211,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 92, "metadata": {}, "outputs": [ { @@ -446,18 +1219,19 @@ "output_type": "stream", "text": [ "\u001b[1m============================= test session starts ==============================\u001b[0m\n", - "platform darwin -- Python 3.8.5, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\n", - "rootdir: /Users/abhijitramesh/development/Python-ifed\n", + "platform linux -- Python 3.8.5, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\n", + "rootdir: /home/lakshmi/my-Python-ifed-challenge\n", + "plugins: anyio-2.0.2\n", "collected 4 items \u001b[0m\n", "\n", "test_abilities.py \u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m.\u001b[0m\u001b[32m [100%]\u001b[0m\n", "\n", - "\u001b[32m============================== \u001b[32m\u001b[1m4 passed\u001b[0m\u001b[32m in 2.75s\u001b[0m\u001b[32m ===============================\u001b[0m\n" + "\u001b[32m============================== \u001b[32m\u001b[1m4 passed\u001b[0m\u001b[32m in 1.05s\u001b[0m\u001b[32m ===============================\u001b[0m\n" ] } ], "source": [ - "!pytest test_abilities.py" + "! pytest test_abilities.py" ] }, { @@ -515,9 +1289,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/__pycache__/ability.cpython-38.pyc b/__pycache__/ability.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8c860a9c4355af9b3d4d65c1790e40f302830e87 GIT binary patch literal 474 zcmYjOO-lnY5S=8uwn|$(2wIOGgbHoYg9i~2^yHxk;-w&E+r;kL-RyRg3M<=F{UPnq zzm%&d{RuresUjVC^O2XCHzbes`VOESf3N!I1mM#Zn?|v?M(90s0tAVn2Z9Rr4m~2s z1GKy^WS~35?tk+!bGSk1J9GvXc)NssSdtkj$$~C%N)u*u1T$us@k%-;b8-t$hcmBa z3%{hL*95^37?*^=J5S_6%upmMM2cX?z*_I+gNc0gBN|Pp9#SV^QuM^u_tdt6I1P(w-&cQ9* zrpgskF^*CsBfU3o{xjvHKn-IMOz`m zIK||SmUNHsO7IUvYnohuyGauPevrV{u)z%qb_cYD4_zACrF#XBnW=+{y_vSw#mui< zC@}J-HNW64sb&9EDQje<>xEZlUYV|Z>w>aPIiE>UPF1b7Y(8Yw$l6ICCVthDcwBbz q_B_RDo4+6e%rQfEMXF#fr4RaW?u2qG#C%|^XtjJ!Kl}7^&i(-_bVjQH literal 0 HcmV?d00001 diff --git a/__pycache__/pokedex.cpython-38.pyc b/__pycache__/pokedex.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b881a2a1df503deaf502abf5c142770094ef2add GIT binary patch literal 1933 zcmcJQ&u<$=6vt;~f5vT0npP2ks4Nw#u+$_4iAxkkR3xf|L=+|MWkqEzo{8gTy=%{o zD-!LV(lZi50*=X%e}+F`ublcXzyZE*)@|$vj*PW$e!VwuX5MF>pD!-97|Pcxe|3Kd z8T*4evqhluCBEVjgk+MZEN*HZb19_rn#Dr8(nIY?Uk0dM$&Xkkd;<%%-{VwGi;vpF z_Z7Y(g)r=rm+XpHyyTbS3hS>jDOOn}j8lpW&RL&T&UDVfxNBVFmF@+<;JfU_gUTzN zOTTnW4|Z;2dj%_4J7hiHk=|ucI#;wK|NNH-rA6YYGDT!gRAkOZD$0+egZxwt^Q>iO z51t%8`DX9g-r>=f?XS-kJ2KJfR#X^0$oh@R;oh_7hx`Ajf5S~QZyX23Nc9G)sNF0X zs@fxUbf`KPkD^Xkhgyv%sxU?E^p&aImqnh{-Uu5owWpJ;uWBb%S?wpIk;)_#@_e<6@L&h0+wyxHZCIyVghCe%J1%gTmB&@Eg-h(E9VU&69knHq+#^I2jH$hiB^t zXXYf&)(6K*uJ=xo6#n{ZlNONb`;F0A9b#*CT?%rs48hthvBX2+^4olguke=8G(1Pe z0tNznmWrRzxTXTp7uRG|j&Y1jk+so(S)pA{qb`Y#8Ox~^W-Cv6(tpiL@6x+syX=Bj ze(8grPphB|P~We@Qh=gR2CHBZ^aM@Y5|oXP#}7+EM4$ge==?iBG8ra)^?&2jcmX{W ztHzmjaAVpfu?SHwH9B3b(!>l9^trnxWzs#uS9}7|XC-^F_N}ORB_u2Psju;VQ3u*B z#gAg_;^d;fHC^>s=fhfLxkaSo)MDdt?VPH!+Iy9x6J>`RaR-ant!>(9FCUI}w#Xw= z4D*@KLl*vh{?W{u8{28#OVVNojkgvS)=sDiCQYeB6D68((Ui4nZ(!80(6?xSR_-j= zE6{DU<2J3+H90QAOmx;<(|cqVz%N}-{Ps|!sqc}I-)!l|G3?yOm@htnV2dr`3c`6w zwD@gj*$qV~+I*Q?y}9eAz0%Gt+P|Z5jkXaI7~2F#h&xDrl=uKR5}ZRgPch#B=7gsm zv$z9li>a6yLjtt8er`l5q~G-Le7sTs@x#iup8aX6C2xSe3XCg5`@f{`uYAeDYnYqUPoz0%S|y#ZlvBX=l1KVQ%6>Nl4TGLLE@@ zK-zsnG42F2p{97=h_?;&e2lL>bdl%uhcLq5P%?}c5@V9ysnSJk!%eemc6N}-8{w_n zNLycY-&s6`UJ*esq^po4b%}dOT`Qq?bVZif<5`(ZY+tYpf}wx?{jwE54_InyaBwy=_3*> zeS!1HgMbz_wjayb4BBY;{&*nNVBLYGKLO!%Obi*3S9DCdg(153*c#E1bzqI{k*(hv z`oZGv$nH??p}k{G99}c_2WLVKJbfSht|1euo`U3|lv>~ic?5FF>5N+w%Ki7w8W}ry z>5&stkX?hj{gFGNujorifgtdgVdo0OAr`tDr=%-n$+h>Z0b!`OW z9j48c9$9;PQ##zba4{cT33TJdOjzGrM`R+!d8neu?$Ko?-#oz}}YipH&cV1zaiQ^kp>&7_Q!$W=Q_a;8Ml1b4LGkEMxI zU3fBs9lAIh>0Z{CyxbafWwy^`l(Iw=^+>ahz!Qp<+hx=^OYbU`sp4eR$yCBjB%bGz zrObe5>V-=fp}OFudFArFa&2C@S}E0OJ7IanO1ZQ(CF&$3;%H~HmnC9TvIE^q;>~2x zdN?q>EN#Ud!CO!UDMi{9o7G=0aTW``kq?SfbEZKwE18XGTLnU(rao!Fa>!HCBr8On z2J5dO`VqW8LbPiw0Q3!j$Kp;2Q1=+1-Z4P$fxiOiV+7+2pdQLU1!!#sP@mWT0H6&3 zXdWK`MEjwq4V0%nT$XXSXVN(Bwp7LyWI;u8xg#(2%e>@JLev)~Js3jh0{ zRJge~7geKmqnd6o?lzP-RI!0Ed2A|bGn>NCZPi#fQ4}_T!m=qmeXgf)zNxaY{2NKe V`%>J5?=#UD(Y56w(z5&Az-Vy)+ literal 0 HcmV?d00001 diff --git a/__pycache__/test_nearest_square.cpython-38-pytest-6.2.1.pyc b/__pycache__/test_nearest_square.cpython-38-pytest-6.2.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..21ad73c5166b0380445a7c92250ce87549b4541b GIT binary patch literal 2032 zcmd6o&2Q646u@W3W5-F_@Lgb8ts)^LEYy#bmbTIcfmU!ps|pFhAs5SZ91_(ZVa64t z*caf)Y4^H^<{17YUw1G07kc8oaZJbP*1Pw@s>YjxLBb0=^V^Z|6zzVI71-c>ld(x>0Q&`a3q9SbQtD-7u z(ANZgLY(>p)+4(P%^Q*LNna(ddU*iK9@=M*1xf|lAJEhh2thNFkd(Zm85JyJDNWfv z%Z$`e9};@R1ZZ6EE%qPFI!o7k^A%Bf||c46Iel*F))d2YZQ6zd%j8z{Dp8=g|WO!NXfjzag& zxT@dCYxf4j1Y_yR{G7Yz1%WI5f!vG30faVR0Jr=6pdTdtNaa=#!wi*QaaAuq2!x*M zz6j#yUf@Pv=;u{ed0ih@$Q$?dSNn1FK+0I=7u;?vLoadt*Mq=|yaYUBE3e}hiVe2P zgWKi7ola@mW-%yM+wSNs7K7H>n8;rs5XbG+UL5+Xfw!-EVShCoE*^ozU&&UF45cw-uPl1RKo`Cof1_)wG z>X3ZE5paO?BZe$B07ss3^%tOmIC706*gwPZPw*EwK11~8;s_X`FEvhZG&PQ<#?hMM zXwAWq0g^m3W=Jl;jwM`gA`wo99<~s>%^8uPl!#pZ63Oi;k`9+uTm@?e(zuCY`|wN& z$reD};e%moO)lcMD)KVEaRuKfrG2A3*pgRI+(qtpPJz(U7!=|f%*-#(%V^YE$J42c zATX!a=UM#??5DE&|K$a8`bBxcJW|N&ti14Vlozh^H?O>y)AC}8%6F6(dv~G}fCrTb zq`vpkMy-xQXBq=9mr&sKDaCE>P1wP8zIGFu;QNl4{iG!s5uBU_q51!Tz%9)KZv8gq z;%kw+4nC)z+p~Hr@%#Bzx2Vu7#g&1oxgz~nvY$Y;Ju&5#sZBO;&-iDcOOix_WfKLi fUdpb{v%VVk?_n$s0{<>vcZE3E