Question: Python 3 pokemon_by_types(db, types): This function accepts a pokemon database db and a list of strings types. It needs to build and return a new

Python 3

pokemon_by_types(db, types): This function accepts a pokemon database db and a list of strings types. It needs to build and return a new database with only pokemon of the given types. NOTE: you must not change the original database with this function. Database for function:

def db1(): return {'Bulbasaur':(1,'Grass','Poison',45,49,49,45,1,False), 'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True), 'Charizard':(6,'Fire','Flying',78,84,78,100, 1,False), 'Charmander':(4,'Fire',None,39,52,43,65,1,False), 'Tornadus, (Incarnate Form)':(641,'Flying',None,79,115,70,111,5,True) }

Example run:>>>(pokemon_by_types(db,["Poison"]) {'Bulbasaur':(1,'Grass','Poison',45,49,49,45,1,False)})

>>>(pokemon_by_types(db1(),["Fire"]) {'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True), 'Charizard':(6,'Fire','Flying',78,84,78,100, 1,False), 'Charmander':(4,'Fire',None,39,52,43,65,1,False)})

>>>(pokemon_by_types(db1(),["Poison","Dragon"] {'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True), 'Bulbasaur':(1,'Grass','Poison',45,49,49,45,1,False)})

>>>(pokemon_by_types(db1(),["Poison","Grass"]) {'Bulbasaur':(1,'Grass','Poison',45,49,49,45,1,False)})

>>>(pokemon_by_types(db1(),["Dark","Water"]), {}

pokemon_by_hp_defense(db, lowest_hp, lowest_defense): Given a pokemon database db and two integers indicating the lowest hit points (hp) and lowest defense stats, this function creates and returns a new database consisting only of pokemon with an hp >= lowest_hp and a defense >= lowest_defense. NOTE: you must not change the original database with this function. Database for function is same as first function.

Example run: >>>pokemon_by_hp_defense(db,100,100) , {'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True)}, >>>pokemon_by_hp_defense(db1(),30,72),

{'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True), 'Charizard':(6,'Fire','Flying',78,84,78,100, 1,False)})

>>>(pokemon_by_hp_defense(db1(),50,40),

{'Reshiram':(643,'Dragon','Fire',100,120,100,90,5,True), 'Charizard':(6,'Fire','Flying',78,84,78,100, 1,False), 'Tornadus, (Incarnate Form)':(641,'Flying',None,79,115,70,111,5,True)})

>>>(pokemon_by_hp_defense(db1(),90,120), {}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!