Question: Project function 5 : battle With the functions we have created so far, we can now finally start creating our battle simulator. This function should
Project function : battle
With the functions we have created so far, we can now finally start creating our battle simulator.
This function should take in two Pokemon pkmn and pkmn as its parameters, and it should output the name of the Pokemon which wins the battle or 'Draw'
Note that we will ignore the cases where one Pokemon can take infinite hits from another Pokemon. We will just consider pairs of Pokemon that can both do nonzero effective damage to each other.
The function should return the name of the Pokemon that can take more hits than the other. If both Pokemon can take the same number of hits, the Pokemon with the higher speed wins. If they both have the same speed, then the
function should return 'Draw' This should sound familiar, because the comparespeed function you wrote in the lab does exactly that.
Points possible:
: def battlepkmn pkmn:
pass # TODO: replace with your code
: studentgrader.checkbattle
Make sure you saved the notebook before running this cell. Running check for battle...
Errors:
Student code does not use: numhits
Student code does not use: comparespeed
Test case failed: Output of battle is incorrect when pkmn can take more hits
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
