Question
Please answer in Python (No for/while loops) This function takes in an unknown number of keyword arguments in the form (pokemon_name = level). The numbers
Please answer in Python (No for/while loops)
This function takes in an unknown number of keyword arguments in the form (pokemon_name = level). The numbers are integers and there will always be at least 1 pair of kwargs. This function produces an energy list and transforms it into a single value according to the given formula: - each pokemon's energy: energy = poke_lvl * poke_atk_val + len(pokemon_name)^2 - combine all the energies into a single-value with: all_energies = sum(abs(pokemon_energies)) Then with the sum of all the pokemon energies, this function returns a function that takes in a threshold value as a num>0 and compares it with the transformed energy. To compare the transformed energy: - If e > threshold: print the energy of the pokemon with the highest energy and return that pokemons name - If e < threshold: print the energy of the pokemon with the lowest energy and return that pokemons name - If e == threshold: The pokemons stop competing and become friends. No print is needed. Return the average of the energy list (convert to integer)
Name | Attack value |
Aggron | 10 |
Alcremie | 3 |
Bagon | 5 |
Bayleef | 4 |
Happiny | 2 |
Pikachu | 4 |
Quagsire | 7 |
Zapdos | 11 |
Example: Input: Alcremie=34, Happiny=49, Zapdos=70 Steps: 1. Compute the energy for each pokemon and save them into a list: Alcremie: 34 * 3 + (8)**2 Happiny: 49 * 2 + (7)**2 Zapdos: 70 * 11 + (6)**2 Energy list = [166, 147, 806] 2. Transform the energy list to a single value: |166|+|147|+|806| = 1119 3. Then a judge gives a threshold of a 1000: Compare 1119 with the threshold: 1119 > 1000 Print 806 and return Zapdos Output: 806 'Zapdos'
Function:
def pokemon_competition(**kwargs): ... return (code here)
Doctests: >>> diff = pokemon_comp(Alcremie=34, Happiny=49, Zapdos=70) >>> diff(1000) 806 'Zapdos' >>> diff(444456) 147 'Happiny' >>> diff(1119) 373 >>> pokemon_comp(Bagon=55, Pikachu=100)(1234) 300 'Bagon'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started