From 0541707be0875203d6b49529e0d43454c542fe92 Mon Sep 17 00:00:00 2001 From: krishkavya Date: Sun, 10 Jan 2021 20:28:18 +0530 Subject: [PATCH] Added --- Python-ifed.ipynb | 1026 ++++++++++++++++- README.md | 1 + __pycache__/ability.cpython-38.pyc | Bin 0 -> 573 bytes __pycache__/nearest_square.cpython-38.pyc | Bin 0 -> 368 bytes ...test_abilities.cpython-38-pytest-6.2.1.pyc | Bin 0 -> 1972 bytes ...nearest_square.cpython-38-pytest-6.2.1.pyc | Bin 0 -> 2018 bytes ability.py | 18 + nearest_square.py | 15 + step4.py | 47 + 9 files changed, 1062 insertions(+), 45 deletions(-) create mode 100644 README.md create mode 100644 __pycache__/ability.cpython-38.pyc create mode 100644 __pycache__/nearest_square.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 step4.py diff --git a/Python-ifed.ipynb b/Python-ifed.ipynb index ee9444d..981d3fe 100644 --- a/Python-ifed.ipynb +++ b/Python-ifed.ipynb @@ -62,15 +62,16 @@ "### Describe what each of the following means\n", "\n", "#### Production\n", - "(Insert answer here)\n", + "The software running on production servers to handle live users and data of the intended audience. \n", "#### Clean \n", - "(Insert answer here)\n", + "readable, simple, and concise. A characteristic of production quality code that is crucial for collaboration and maintainability in software development.\n", + "\n", "#### Modular\n", - "(Insert answer here)\n", + " logically broken up into functions and modules. Also an important characteristic of production quality code that makes your code more organized, efficient, and reusable.\n", "#### Module\n", - "(Insert answer here)\n", + "a file. Modules allow code to be reused by encapsulating them into files that can be imported into other files.\n", "#### Refactoring code\n", - "(Insert answer here)" + "Code refactoring is defined as the process of restructuring computer code without changing or adding to its external behavior and functionality." ] }, { @@ -93,9 +94,214 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "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": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import pandas as pd\n", "df = pd.read_csv('matches.csv', sep=',')\n", @@ -113,9 +319,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": [ "new_df = df.rename(columns={'team 1': 'team_1',\n", " 'team 2': 'team_2',\n", @@ -139,9 +550,214 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "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": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "labels = list(df.columns)\n", "labels[0] = labels[0].replace(' ', '_')\n", @@ -167,11 +783,220 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "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": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Insert your solution here" + "labels = list(df.columns)\n", + "for i in range(len(labels)):\n", + " labels[i] = labels[i].replace(' ','_')\n", + "df.columns = labels\n", + "df.head()" ] }, { @@ -208,7 +1033,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -219,7 +1044,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -233,9 +1058,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 7.4446024894714355 seconds\n" + ] + } + ], "source": [ "start = time.time()\n", "verified_elements = []\n", @@ -257,14 +1091,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 68, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 0.09533023834228516 seconds\n" + ] + } + ], "source": [ - "# Insert answer here\n", + "start = time.time()\n", "\n", - "print(len(verified_elements))\n", - "print('Duration: {} seconds'.format(time.time() - start))" + "x = np.intersect1d(np.array(subset_elements), np.array(all_elements)) \n", + "\n", + "print(len(x))\n", + "print(f'Duration: {time.time() - start} seconds')" ] }, { @@ -276,13 +1121,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "96\n", + "Duration: 0.0049016475677490234 seconds\n" + ] + } + ], "source": [ - "# Insert answer here\n", - "\n", - "print(len(verified_elements))\n", + "start = time.time()\n", + "c=set(subset_elements).intersection(all_elements)\n", + "print(len(c))\n", "print('Duration: {} seconds'.format(time.time() - start))" ] }, @@ -330,9 +1184,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m============================= test session starts ==============================\u001b[0m\n", + "platform linux -- Python 3.8.5, pytest-6.2.1, py-1.10.0, pluggy-0.13.1\n", + "rootdir: /home/ubuntu/Python-ifed\n", + "plugins: anyio-2.0.2\n", + "collected 4 items \u001b[0m\n", + "\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\n", + "\n", + "\u001b[32m============================== \u001b[32m\u001b[1m4 passed\u001b[0m\u001b[32m in 0.01s\u001b[0m\u001b[32m ===============================\u001b[0m\n" + ] + } + ], "source": [ "! pytest test_nearest_square.py" ] @@ -386,11 +1256,27 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "electric\n" + ] + } + ], "source": [ - "# Insert your code here" + "import requests, json\n", + "response = requests.get('https://pokeapi.co/api/v2/pokemon/25')\n", + "text = json.dumps(response.json(), sort_keys=True, indent=4)\n", + "json_object = json.loads(text)\n", + "pairs = json_object.items()\n", + "a = json_object['types']\n", + "b = a[0]\n", + "c = b['type']\n", + "print(c['name'])" ] }, { @@ -404,11 +1290,31 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ground\n" + ] + } + ], "source": [ - "# Insert your code here" + "import requests, json\n", + "response = requests.get('https://pokeapi.co/api/v2/pokemon/25')\n", + "text = json.dumps(response.json(), sort_keys=True, indent=4)\n", + "json_object = json.loads(text)\n", + "pairs = json_object.items()\n", + "a = json_object['name']\n", + "#print(a)\n", + "response = requests.get('https://pokeapi.co/api/v2/type/13')\n", + "text = json.dumps(response.json(), sort_keys=True, indent=4)\n", + "json_object = json.loads(text)\n", + "a= json_object['damage_relations']\n", + "b = a['double_damage_from']\n", + "print(b[0]['name'])" ] }, { @@ -420,11 +1326,40 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Type: ground\n", + "sandshrew\n", + "sandslash\n", + "nidoqueen\n", + "nidoking\n", + "diglett\n" + ] + } + ], "source": [ - "# Insert your code here" + "import requests, json\n", + "\n", + "response = requests.get('https://pokeapi.co/api/v2/type/13')\n", + "text = json.dumps(response.json(), sort_keys=True, indent=4)\n", + "json_object = json.loads(text)\n", + "a= json_object['damage_relations']\n", + "b = a['double_damage_from']\n", + "print(\"Type: \",b[0]['name'])\n", + "\n", + "pokemon = requests.get('https://pokeapi.co/api/v2/type/5')\n", + "name = json.dumps(pokemon.json(), sort_keys=True, indent=4)\n", + "json_object2 = json.loads(name)\n", + "for i in range(5):\n", + " a = json_object2['pokemon']\n", + " b = a[i]\n", + " c = b['pokemon']\n", + " print(c['name'])" ] }, { @@ -438,7 +1373,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -446,13 +1381,14 @@ "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/ubuntu/Python-ifed\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 4.21s\u001b[0m\u001b[32m ===============================\u001b[0m\n" ] } ], @@ -515,9 +1451,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/README.md b/README.md new file mode 100644 index 0000000..9de6ac3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Python-ifed \ 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..eb518573d0c17fb5ec20eeb733031f72cf05f161 GIT binary patch literal 573 zcmYjPy>1jS5cb&Kzk^69LWD?EP;J4jM2S$uUmYPKnw3zrcXsaf*tIunZ^R*Q6aOGwconx)d4-6A@m+*6)_k95JTo5ud^$Lo5R~74Z_a)KA%B8#S11~buHcAlVFb%o+`)!zNvQUN zj?}VEyF|?iWQKKt?)K_XDJ!_=$an*HFiG0$BI|(IB zrQ)xRY*2P6KCJCh ztLOE(6vb_u({9~|!!T6y2!X&M9MTEn@DS45ai8vDa@NNf&}RWc(r%AC@ECnQebs6) OH1Z@ouL-~60sRM@8IE=U literal 0 HcmV?d00001 diff --git a/__pycache__/nearest_square.cpython-38.pyc b/__pycache__/nearest_square.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e932cb9b46481f33ce263c487db8b2baa4037fa3 GIT binary patch literal 368 zcmY*TO-sW-6nt-!NDQeb5%CX51&aOIemt1B^Y+co?Bi$@5o)^Iug;n1!wr8+V7LQJj3!C)J1t3y1&zHI=zq!sb9eyE z9L++Tk&Y!V92c3dr_yWLGA8egGS>Itd`zvd!cr#m#KPCI^slMq>J&PELM>IX^pO|L zde~C$QhN8T-sSJ`kuKPzd0KazE)PuAJZYr^tiId+B3YNYN}A`UsGDTIt=DC7nZ7ES z6bedHuZAaAZ`4rWIIs}AF1*Q0*=*FUbNU46 E3*VMVTL1t6 literal 0 HcmV?d00001 diff --git a/__pycache__/test_abilities.cpython-38-pytest-6.2.1.pyc b/__pycache__/test_abilities.cpython-38-pytest-6.2.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6448beb1ff8f7be166e03a4a64fb98c4761378b GIT binary patch literal 1972 zcmds2%WD%s7@yf!HfdU@k6LfN2(FN}z7?z};-!cPJ`Q_XCYedHbYINOS`(9t^(@k} z2LmGHUs~|w$v?rK{Jz~-5>Y{Kx?#TO?9Ajhzwg_p%gYS{&!;zEgF{NlXLRNt1DrcB z)Gi24IE{!;OKrraK`4nW-=>%`A}4ly2W*pDuZdsdHg`a~yvAM7bzbKU&<#!>6L0AY ztVbStw5YLm7=?P!!NB*&0iy=v9t`yn1gB%7$%q`#G35qs(KE-!h>nasV{DF0b*Slk zgWDssOSyybt}(HAO`Gqn3E6Yh1IXK&OsISYmV;JeKpyN7*rld3ZA>V4-&t#9Y~i6t zR!G6NHO_WN_JkhLR{(-V#yBVpI14BEw;uYnn05Lr&U~wvYc+I}wAIU*&tk)SwroZ59Oyi$zfn6zd9Hp;)oxwt(g@+1IpbYZKX#$qdP=ZVg@9u0Iq zOI{5k=Gz%9C@0mCBCNRzA(c^aa>Cglgn{z%H6 zu|UbUKo^5sB_-`+N;=1s+=YBa$tOs^86_RGe@e;PjFK*|{{bZ%K*=oJ15)O`qcmJd zXSf`Ny}nMuq}P%umxzM2Q6Rk}7N5lGlP-!n3dE?yyb`Ct{Q=S09{BPcqV7DRYmoat z5UoRr%W#NgZMP#f6vHKzMohM{bYIB71$1qJqQ_g{1^f!qGrxuO-|C#U5YL4ex-w5% zY@ZGMCgUvAv+o0V32-;e%9irC5U(ykjQceg(OqZ(>yY!73io?!lsLIK8&u77v+8Hi z;5Mb$m!XEncpNHfvzWvWY*kp;Q6v_D#A}nd`dm$6N0Vh?xwqn!=aIM#Uu2?iPnVn^ JO~W zpsA-|1Q9eKEvkFgH5j3!%UdSJ2n(#P)v~}h1piE0C1DB+dRvr)4SiXZMFskbpf8A1 z9m9TP%b{5<^gZdT*i~=);OyZ1^k;!ng7yfS+6Nin+lHeZ8qe>jE#LhByTMB1mb2)hEzTW&q6O`5C=a2U-xv{5RX$9d z`eq%yB}d)De%Vn@C9QAfvulo$nD!CR3|NC^xdmng&DufDQ_7dI-eAK~7~U9_^%Gg; zL2nRaEsm~8lvLEH&dW(5(fP}wC{?MD4T=%w!KAlmi< zH}txGR(6%w_Hl=-_E5jI6NQhZjAVAsZAY@}#jgLp7kHr;Lu6!SReVE!z-Do9r#QIV zDlA*g2l;O6Eq%m%&|Df3c?A-2&}i&NUBA)a?uT)|@q7^PM&a#F+ZPS}u}1+~>3JIVonN*B}#u$Q0%R-763m~B9Qu~OB=l^8m%-YUM`@)3scD3 z%$u-*`~2!A)FJj4Ir~qGFd{fU4My|-4~bit1>Eu-)Z$l}y8$t$n%UC|EAjo=WjC+M zi}{s-I=LwQcd`>heLbAYN|QNR!!u*~*Ck0J!Lp79cQ2@`b=FtIzSoUJKk)D4bytXk LP0o@zX6ye?$gbSV literal 0 HcmV?d00001 diff --git a/ability.py b/ability.py new file mode 100644 index 0000000..2155a7c --- /dev/null +++ b/ability.py @@ -0,0 +1,18 @@ +import requests, json + +def ability(name): + response = requests.get('https://pokeapi.co/api/v2/pokemon/' + str(name)) + text = json.dumps(response.json(), indent=4) + + json_object = json.loads(text) + + + A = [] + for i in range(len(json_object['abilities'])): + a= json_object['abilities'] + b = a[i] + c = b['ability'] + final = c['name'] + A.append(final) + + return A \ No newline at end of file diff --git a/nearest_square.py b/nearest_square.py new file mode 100644 index 0000000..8fe0895 --- /dev/null +++ b/nearest_square.py @@ -0,0 +1,15 @@ +def nearest_square(limit): + if limit < 0: + return 0 + + while limit > 3: + i = 2 + while i <= limit//2: + square = i*i + if square == limit: + return square + else: + i += 1 + limit -= 1 + return 1 + \ No newline at end of file diff --git a/step4.py b/step4.py new file mode 100644 index 0000000..95b8f50 --- /dev/null +++ b/step4.py @@ -0,0 +1,47 @@ +import time +import pandas as pd +import numpy as np + +with open('subset_elemets.txt') as f: + subset_elements = f.read().split('\n') + +with open('all_elements.txt') as f: + all_elements = f.read().split('\n') + +def Number_elements(file1,file2): + """Defined a function named Number_elements.This also contains intersect1d function from numpy module. + ##parameters + file1,file2 + + ##Returns: + returns the total number of elements present in both the files. + """ + start = time.time() + + verified_element = np.intersect1d(np.array(file1), np.array(file2)) + + print(len(verified_element)) + print(f'Duration: {time.time() - start} seconds') + +Number_elements(subset_elements, all_elements) + +Method_one(subset_elements, all_elements) + +# This is using datastructures + +def Method_two(file1,file2): + """Defined a function named Method_two.This also uses the built in function intersection to find out the elements that are present as common in both the files. + ##parameters + file1,file2 + + ##Returns: + returns the total number of elements present in both the files. + """ + start = time.time() + + verified_element=set(file1).intersection(file2) + + print(len(verified_element)) + print('Duration: {} seconds'.format(time.time() - start)) + +Method_two(subset_elements, all_elements)