Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 63 additions & 35 deletions Python-ifed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,23 @@
"### Describe what each of the following means\n",
"\n",
"#### Production\n",
"(Insert answer here)\n",
"Production code is the code which is installed and used on a live and the running of the business depends on the code itself then it is called as Production code.\n",
"\n",
"And in other words if Others rely on the code who doesn't know what the code is then it called as the producton code.\n",
"\n",
"#### Clean \n",
"(Insert answer here)\n",
"The code that is easy to read,understand,modify and having no errors and maintains all the PEP8 architechture is called a clean code.And it consists of all the functions,variable,class names clear and maintainsuniqueness.\n",
"\n",
"#### Modular\n",
"(Insert answer here)\n",
"Modular means a design approach that sub divides a system into smaller parts that can be independently created and then used in different time for programmers.\n",
"This is followed for better understanding and uniqueness among the team. \n",
"\n",
"#### Module\n",
"(Insert answer here)\n",
"A file in which all the set of functions you want to include in your application are written and stored is called a Module.\n",
"And we use functions by calling from this file.\n",
"\n",
"#### Refactoring code\n",
"(Insert answer here)"
"The process of restructuring the codebase withour changing or adding to its external behaviour and functionality is called Refactoring code."
]
},
{
Expand Down Expand Up @@ -171,7 +179,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Insert your solution here"
"df.columns= df.columns.str.replace(' ','_')\n",
"df.head()"
]
},
{
Expand Down Expand Up @@ -261,7 +270,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Insert answer here\n",
"start = time.time()\n",
"verified_elements=np.intersect1d(all_elements,subset_elements)\n",
"\n",
"print(len(verified_elements))\n",
"print('Duration: {} seconds'.format(time.time() - start))"
Expand All @@ -280,7 +290,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Insert answer here\n",
"start = time.time()\n",
"verified_elements=set(all_elements).intersection(subset_elements)\n",
"\n",
"print(len(verified_elements))\n",
"print('Duration: {} seconds'.format(time.time() - start))"
Expand Down Expand Up @@ -386,11 +397,17 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Insert your code here"
"import requests\n",
"import json\n",
"response=requests.get(\"https://pokeapi.co/api/v2/pokemon/jigglypuff\")\n",
"types=response.json()['types']\n",
"for i in types:\n",
" j=i['type']\n",
" print(j['name'])"
]
},
{
Expand All @@ -404,11 +421,25 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Insert your code here"
"Typename_furtheruse=[]\n",
"for i in types:\n",
" j=i['type']\n",
" url=j['url'] #Getting url\n",
" damage_relations=requests.get(url).json()['damage_relations'] #requesting the data\n",
" double_damage_from=damage_relations['double_damage_from']\n",
"\n",
" half_damage_from=damage_relations['half_damage_from']\n",
" for l in double_damage_from:\n",
" print(l['name'])\n",
" Typename_furtheruse.append(l['name'])#For nxtstep\n",
" for m in half_damage_from:\n",
" print(m['name'])\n",
" \n",
" '''Getting the url from the types as that url conatains the damage_relations then getting the data from that respective url from where the damage(double_damage and half_damage) is coming from'''"
]
},
{
Expand All @@ -420,11 +451,23 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Insert your code here"
"for i in Typename_furtheruse:\n",
" poke_response=requests.get(\"https://pokeapi.co/api/v2/type/\"+i) \n",
" pokemon=(poke_response.json()['pokemon']) #by observing the json data.\n",
" k=0\n",
" print(f\"5 Pokemons in the type {i}\")\n",
" for i in pokemon:\n",
" if k<5:\n",
" j=(i['pokemon'])\n",
" print(j['name'])\n",
" k=k+1\n",
" print('\\n')\n",
"\n",
"'''First got the type from the list created in the previous step and then got the names of that type from the API'''"
]
},
{
Expand All @@ -438,24 +481,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"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",
"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"
]
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pytest test_abilities.py"
]
Expand Down Expand Up @@ -501,9 +529,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.8.5 64-bit",
"language": "python",
"name": "python3"
"name": "python38564bit513a40913b454c2d84d7ec38112f5972"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -515,7 +543,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.8.5-final"
}
},
"nbformat": 4,
Expand Down
Binary file added __pycache__/ability.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/nearest_square.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions ability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import requests
import json
def ability(pokeName):
response=requests.get("https://pokeapi.co/api/v2/pokemon/"+pokeName)
abilities=response.json()['abilities']
ability=[]
for i in abilities:
j=(i['ability'])
ability.append(j['name'])
return ability
25 changes: 25 additions & 0 deletions nearest_square.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import math

def perfect_numb(n):
if (math.sqrt(n)-math.floor(math.sqrt(n))==0):
return True
return False
def nearest_square(n):
if n<0:
return 0
quit()
if perfect_numb(n):
return int(n)
else:
smaller_numb= -1
i=0
i=n+1

i =n-1
while True:
if perfect_numb(i):
smaller_numb=i
break
else:
i=i-1
return ((smaller_numb))
99 changes: 99 additions & 0 deletions pokedex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import tkinter as tk
import requests

def get_pokemon_type(pokemon):
type=[]
response=requests.get("https://pokeapi.co/api/v2/pokemon/"+pokemon)
types=response.json()['types']
for i in types:
j=i['type']
type.append(j['name'])
return type


def get_pokemon_damage(pokemon):
response=requests.get("https://pokeapi.co/api/v2/pokemon/jigglypuff")
types=response.json()['types']
types_caused_damage=[]
for i in types:
j=i['type']
url=j['url'] #Getting url
damage_relations=requests.get(url).json()['damage_relations'] #requesting the data
double_damage_from=damage_relations['double_damage_from']

half_damage_from=damage_relations['half_damage_from']
for l in double_damage_from:
types_caused_damage.append(l['name'])#For nxtstep
for m in half_damage_from:
types_caused_damage.append(m['name'])
return types_caused_damage


def get_pokemon_doubledamageNames(pokemon):
response=requests.get("https://pokeapi.co/api/v2/pokemon/"+pokemon)
types=response.json()['types']
poke_caused_doubledamage=[]
for i in types:
j=i['type']
url=j['url'] #Getting url
damage_relations=requests.get(url).json()['damage_relations'] #requesting the data
double_damage_from=damage_relations['double_damage_from']
for l in double_damage_from:
poke_response=requests.get("https://pokeapi.co/api/v2/type/"+l['name'])
poke=(poke_response.json()['pokemon']) #by observing the json data.
k=0
for i in poke:
if k<5:
j=(i['pokemon'])
poke_caused_doubledamage.append(j['name'])
k=k+1
return poke_caused_doubledamage


def show_pokemon_data():
pokemon_name=txt_pokemon_name.get()

pokemon_data_type=get_pokemon_type(pokemon_name)
lbl_type_value.config(text= pokemon_data_type)

pokemon_data_causeddamage=get_pokemon_damage(pokemon_name)
lbl_damage_value.config(text=pokemon_data_causeddamage)

pokemon_data_doubledamageName=get_pokemon_doubledamageNames(pokemon_name)
lbl_doubledamageName_value.config(text=pokemon_data_doubledamageName)


window=tk.Tk()
window.config(bg='#edafab')
window.title('PokeDex')

# From here all the labels and the values that should be given to those labels starts.

lbl_instructions = tk.Label(window, text ="Enter the name of pokemon")
lbl_instructions.pack()

txt_pokemon_name = tk.Entry(window)
txt_pokemon_name.pack()

btn_get_info = tk.Button(window,text="Get Data!",command= show_pokemon_data)
btn_get_info.pack()

lbl_type_text=tk.Label(window,text="Type",fg='#1c03fc')
lbl_type_text.pack()
lbl_type_value=tk.Label(window,text="???")
lbl_type_value.pack()

lbl_damage_text=tk.Label(window,text="Damage caused by",fg='#1c03fc')
lbl_damage_text.pack()
lbl_damage_value=tk.Label(window,text="???")
lbl_damage_value.pack()

lbl_doubledamageName_text=tk.Label(window,text="Pokemons from each type caused double damage",fg='#1c03fc')
lbl_doubledamageName_text.pack()
lbl_doubledamageName_value=tk.Label(window,text="???")
lbl_doubledamageName_value.pack()

window.mainloop()



42 changes: 42 additions & 0 deletions step_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
def lists_intersection(biglst1,smalllst2):

"""Returns the lenght of intersection of two lists"""

print(lists_intersection.__doc__)
#help(list_intersection) """We can also get the Documentation of the function with the help of this """

print (len(set(biglst1).intersection(smalllst2))) #Using the function named as intersection1d from numpy.


def read_txt_file(filename):

"""Reads the data of the txt file and returs the file by seperating them line by line"""
print(read_txt_file.__doc__)
with open(filename) as f:
return f.read().split('\n')


import numpy as np
"""imports numpy as np. Numpy is an python library used for working with arrays
it also has functions for working in domain of linear algebra,matrices.
This library must be installed from the web,Or by using "pip install numpy"

"""

import pandas as pd
"""imports pandas as pd. Pandas is an python library used for data manipulation and analysis.
This library must be installed from the web,Or by using "pip install pandas"

"""

import time
"""imports time module which comes with python by defualt."""


subset_elements=read_txt_file('subset_elemets.txt')
all_elements=read_txt_file('all_elements.txt')

start = time.time()
lists_intersection(all_elements,subset_elements)
print('Duration: {} seconds'.format(time.time() - start))