From c31487a3f600416ac8410890bf7f4d6202cd28ee Mon Sep 17 00:00:00 2001 From: Ragify <73241561+Ragify@users.noreply.github.com> Date: Sun, 10 Jan 2021 20:43:27 +0530 Subject: [PATCH] Update --- Python-ifed.ipynb | 437 +++++++++++++++--- __pycache__/ability.cpython-39.pyc | Bin 0 -> 510 bytes __pycache__/nearest_square.cpython-39.pyc | Bin 0 -> 356 bytes ...test_abilities.cpython-39-pytest-6.2.1.pyc | Bin 0 -> 1935 bytes ...nearest_square.cpython-39-pytest-6.2.1.pyc | Bin 0 -> 1979 bytes ability.py | 10 + nearest_square.py | 7 + pokedex.py | 90 ++++ step_4.py | 60 +++ 9 files changed, 548 insertions(+), 56 deletions(-) create mode 100644 __pycache__/ability.cpython-39.pyc create mode 100644 __pycache__/nearest_square.cpython-39.pyc create mode 100644 __pycache__/test_abilities.cpython-39-pytest-6.2.1.pyc create mode 100644 __pycache__/test_nearest_square.cpython-39-pytest-6.2.1.pyc create mode 100644 ability.py create mode 100644 nearest_square.py create mode 100644 pokedex.py create mode 100644 step_4.py diff --git a/Python-ifed.ipynb b/Python-ifed.ipynb index ee9444d..9749e60 100644 --- a/Python-ifed.ipynb +++ b/Python-ifed.ipynb @@ -27,8 +27,6 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, "source": [ "## Step 0\n", "\n", @@ -47,7 +45,11 @@ "https://www.atlassian.com/git\n", "\n", "https://www.tutorialspoint.com/git/git_basic_concepts.htm" - ] + ], + "cell_type": "code", + "metadata": {}, + "execution_count": null, + "outputs": [] }, { "cell_type": "markdown", @@ -62,15 +64,15 @@ "### Describe what each of the following means\n", "\n", "#### Production\n", - "(Insert answer here)\n", + "The code that is reliable and is the final version and which is available to the client is called Production Code.\n", "#### Clean \n", - "(Insert answer here)\n", + "The code that is easily readable and understandable to both the author and anyone who has access to the code is called Clean Code.\n", "#### Modular\n", - "(Insert answer here)\n", + "The code which can be divided into independent blocks which when combined produces a meaningful code is called Modular Code.\n", "#### Module\n", - "(Insert answer here)\n", + "The individual piece of code is called a Module.\n", "#### Refactoring code\n", - "(Insert answer here)" + "The process of restructuring or simplifying the design of a code without changing its logic or behaviour is called Refactoring Code." ] }, { @@ -93,9 +95,59 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "execute_result", + "data": { + "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 " + ], + "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
" + }, + "metadata": {}, + "execution_count": 6 + } + ], "source": [ "import pandas as pd\n", "df = pd.read_csv('matches.csv', sep=',')\n", @@ -113,9 +165,59 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "execute_result", + "data": { + "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 " + ], + "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
" + }, + "metadata": {}, + "execution_count": 31 + } + ], "source": [ "new_df = df.rename(columns={'team 1': 'team_1',\n", " 'team 2': 'team_2',\n", @@ -139,9 +241,59 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "execute_result", + "data": { + "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 " + ], + "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
" + }, + "metadata": {}, + "execution_count": 30 + } + ], "source": [ "labels = list(df.columns)\n", "labels[0] = labels[0].replace(' ', '_')\n", @@ -167,11 +319,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "execute_result", + "data": { + "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 " + ], + "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
" + }, + "metadata": {}, + "execution_count": 8 + } + ], "source": [ - "# Insert your solution here" + "new_df=df\n", + "new_df.columns = df.columns.str.replace(' ','_')\n", + "new_df.head" ] }, { @@ -182,8 +386,6 @@ ] }, { - "cell_type": "markdown", - "metadata": {}, "source": [ "# Step 3\n", "\n", @@ -204,11 +406,15 @@ "\n", "https://towardsdatascience.com/one-simple-trick-for-speeding-up-your-python-code-with-numpy-1afc846db418\n", "\n" - ] + ], + "cell_type": "code", + "metadata": {}, + "execution_count": null, + "outputs": [] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -219,7 +425,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -233,9 +439,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "96\nDuration: 11.977692365646362 seconds\n" + ] + } + ], "source": [ "start = time.time()\n", "verified_elements = []\n", @@ -257,11 +471,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "96\nDuration: 0.028920412063598633 seconds\n" + ] + } + ], "source": [ - "# Insert answer here\n", + "start=time.time()\n", + "verified_elements=np.intersect1d(subset_elements,all_elements)\n", "\n", "print(len(verified_elements))\n", "print('Duration: {} seconds'.format(time.time() - start))" @@ -276,11 +499,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "96\nDuration: 0.005990028381347656 seconds\n" + ] + } + ], "source": [ - "# Insert answer here\n", + "start=time.time()\n", + "verified_elements=list(set(all_elements)&set(subset_elements))\n", "\n", "print(len(verified_elements))\n", "print('Duration: {} seconds'.format(time.time() - start))" @@ -330,9 +562,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "============================= test session starts =============================\nplatform win32 -- Python 3.9.1, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\nrootdir: c:\\Users\\Anurag\\Documents\\GitHub\\Python-ifed-challenge-\ncollected 4 items\n\ntest_nearest_square.py .... [100%]\n\n============================== 4 passed in 0.02s ==============================\n" + ] + } + ], "source": [ "! pytest test_nearest_square.py" ] @@ -386,11 +626,28 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 71, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Type 1: normal\nType 2: fairy\n" + ] + } + ], "source": [ - "# Insert your code here" + "import requests\n", + "\n", + "url = \"http://pokeapi.co/api/v2/pokemon/jigglypuff/\"\n", + "\n", + "payload = \"\"\n", + "response = requests.request(\"GET\", url, data=payload)\n", + "\n", + "data = response.json()\n", + "print(\"Type 1:\",data[\"types\"][0][\"type\"][\"name\"])\n", + "print(\"Type 2:\",data[\"types\"][1][\"type\"][\"name\"])\n" ] }, { @@ -404,11 +661,43 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], + "execution_count": 72, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "fighting\npoison\nsteel\nfighting\nbug\ndark\n" + ] + } + ], "source": [ - "# Insert your code here" + "url1=(data[\"types\"][0][\"type\"][\"url\"])\n", + "url2=(data[\"types\"][1][\"type\"][\"url\"])\n", + "\n", + "payload1 = \"\"\n", + "payload2 = \"\"\n", + "\n", + "response1 = requests.request(\"GET\", url1, data=payload1)\n", + "response2 = requests.request(\"GET\", url2, data=payload2)\n", + "\n", + "data1 = response1.json()\n", + "data2 = response2.json()\n", + "\n", + "for i in range(len(data1[\"damage_relations\"][\"double_damage_from\"])):\n", + " print(data1[\"damage_relations\"][\"double_damage_from\"][i][\"name\"])\n", + " \n", + "for i in range(len(data2[\"damage_relations\"][\"double_damage_from\"])):\n", + " print(data2[\"damage_relations\"][\"double_damage_from\"][i][\"name\"])\n", + "\n", + "for i in range(len(data1[\"damage_relations\"][\"half_damage_from\"])):\n", + " print(data1[\"damage_relations\"][\"half_damage_from\"][i][\"name\"])\n", + "\n", + "for i in range(len(data2[\"damage_relations\"][\"half_damage_from\"])):\n", + " print(data2[\"damage_relations\"][\"half_damage_from\"][i][\"name\"])\n" ] }, { @@ -420,11 +709,50 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 74, "metadata": {}, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "mankey,primeape,poliwrath,machop,machoke,\n", + "\n", + "bulbasaur,ivysaur,venusaur,weedle,kakuna,\n", + "\n", + "magnemite,magneton,forretress,steelix,scizor,\n", + "\n" + ] + } + ], "source": [ - "# Insert your code here" + "url1=(data[\"types\"][0][\"type\"][\"url\"])\n", + "url2=(data[\"types\"][1][\"type\"][\"url\"])\n", + "\n", + "payload=\"\"\n", + "payload1 = \"\"\n", + "payload2 = \"\"\n", + "\n", + "response = requests.request(\"GET\", url, data=payload)\n", + "response1 = requests.request(\"GET\", url1, data=payload1)\n", + "response2 = requests.request(\"GET\", url2, data=payload2)\n", + "\n", + "pdata = response.json()\n", + "data1 = response1.json()\n", + "data2 = response2.json()\n", + "\n", + "ddf=[]\n", + "for i in range(len(data1[\"damage_relations\"][\"double_damage_from\"])):\n", + " ddf.append(data1[\"damage_relations\"][\"double_damage_from\"][i][\"url\"])\n", + "\n", + "for i in range(len(data2[\"damage_relations\"][\"double_damage_from\"])):\n", + " ddf.append(data2[\"damage_relations\"][\"double_damage_from\"][i][\"url\"])\n", + "\n", + "for i in range(len(ddf)):\n", + " pdata = requests.request(\"GET\", ddf[i], data=payload).json()\n", + " for j in range(5):\n", + " print(pdata[\"pokemon\"][j][\"pokemon\"][\"name\"],end=',')\n", + " print(\"\\n\")" ] }, { @@ -438,21 +766,14 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 68, "metadata": {}, "outputs": [ { - "name": "stdout", "output_type": "stream", + "name": "stdout", "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", - "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" + "============================= test session starts =============================\nplatform win32 -- Python 3.9.1, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\nrootdir: c:\\Users\\Anurag\\Documents\\GitHub\\Python-ifed-challenge-\ncollected 4 items\n\ntest_abilities.py .... [100%]\n\n============================== 4 passed in 1.38s ==============================\n" ] } ], @@ -501,9 +822,13 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" + "name": "python3", + "display_name": "Python 3.9.1 64-bit", + "metadata": { + "interpreter": { + "hash": "bb11029e2afac0e7f6618262482e01595b9fa9c6642c63436503e9a1c447fc40" + } + } }, "language_info": { "codemirror_mode": { @@ -515,7 +840,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.9.1-final" } }, "nbformat": 4, diff --git a/__pycache__/ability.cpython-39.pyc b/__pycache__/ability.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..37b97cea4405c43c5fbd5286a9ba86c743c0c268 GIT binary patch literal 510 zcmYjOO;6k~5S>Y!4=TP62(-r@b66r(J)sIg3xX3uD!oLhDigcAp;`~nw3@H4;vv7lg_1JqNxc3LY_aD4R7}yMk zpl2eSzzKZa9l}0%@cU3i6AduZ7Yo>>4iCVW3+N1uWPA9 z5;Y;c#rbVhWl_z$N^>z*nOZ9&8%AOlaBANSuF|A5|ls6Rl&4-|ASi%`5Qfu%OtcCk%0NreTE{t!L-mwFOB z^(W{>UltGRgZJi5hMCD^!{Igo`#)c^C&W*mtb-#t1MMC}l4KQ4Npcyy(3DA*QXKZE z&?IL*{K5MWya4S1rZ()%{!r2v7C)86loc^B51 zE4#tGY8n%>j_G$Yn<#yc^CNLvq5!KXw(7pBT#r-dUbBsjE`jIUKmUl|P(nVS zv-()z+=8YbfZ&8vNg~>4E3+*^N#;Z@#U4v~nHPCr+uV6cq7HYt2ioTy?t>0^z`LNk zoc>C}wclYr@-U=zhYeDhn(+_=M~??a2ihHI`aK9vXT*>xc|m71fyLg@nKh+T>#;Sn zr?!4&=v#|}HKN?X_{f?&+%@)FXHK5L?xEi`WKPv@V0mce7W9KX1-sF7sjWHX-fL%z z%pBbM)JZAWuIa!if9lTZ3;G-&aL5cBg=WtzPT)|%!>E(7;XcdC(2ks>GJ4|YMK7tC z;!&WDV0^^1SFnA(`rx#eq;?3*go#6g*x60Y8H9%ojoUUoMoc5Kn{%?TN3d zyvGjMI9g|%m1g-n051n_re#w>z82EWPawq=*H_Ry3wF3x`$v^eVP}0VZfoUETdtsf z?I>}eQUi7GI8=9*F@^unHc_xbC?vVUYf?D-N{%$y(jN_n6h&be2%3W+fS|RMErcSK zT`H+u@)Gx$Q_eY9NA)N1+LL}leQ9Twl0nBpisTdtJ3F(p+{etfQ-BgQk7~A&8(pX;9s>uE7W;UEVM$dYEr@t%e1hz<2NqGwEi)~15vc$*EmFeBrP56LT{egeN4ks*}_pjoH|4E&(SpzEGadN!oO zde0X~!twMm?@-Xqr~tEyu{ort^bJITlLQ-uW+Y4yxL0X^Y{EIm9K?v8v)$bhJz4wq zL2s~OtMVTcrMg>1ZOv8>u&>+7E+^I9Y;?<362m^?sR46P)Egi+P;8ygyGnU7(hKa^ z3f()SlKvts@AU=|#?qDPO{eAhz9YS!Y=zw(gf_hfZs)My@uNL!72s|Szt>6yX z0c&|$a4p>1Rx#khZKj86K@MkHZFKH zHIJs|(VFmR&ESy%lRPn|OkRT%OL*TzBAqrpsUdfpQzSvjA-Qsu$?XY~HkTz_1&apa zxQSx>R1>bVHLIGKlWJm#!Y5Rd;{I5N8?Pl1 zKmE*Q5w!{momULATtI=ZB^RZcobTW|(->7j|AZKQp%oVa8{Yt->HdsBEzH8HzK*e< zM(Q5ub|o!N%csQs(q$(rxU1O%fFigmz1Ol6LGip8N(+-QIge+=5~B-@L_%d11+JdU ap3b8Nz4%=>6n)=&jE`4g;_tJf{{IK