![]() | |
Teachers Assignments Assignments Other Pages | Project 11: Assigned: Wed Nov 20 2024 In this project, you'll create write more sophisticated functions to handle Pokemon objects. Part 0, 2 points: It's very annoying to use six lines to create a single Pokemon object. Let's write a function, >>> gary = create_pokemon('Gyarados', 130, ['Water', 'Flying'], 83)
>>> print_pokemon(gary)
Pokemon: Gyarados (130) HP: 83/83
>>> vandal = create_pokemon('Jigglypuff', 39, ['Normal', 'Fairy'], 44)
>>> print_pokemon(vandal)
Pokemon: Jigglypuff (39) HP: 44/44 Tester.Part 1, 4 points: Let's write a function to revive fainted Pokemon. >>> gary = create_pokemon('Gyarados', 130, ['Water', 'Flying'], 83)
>>> gary.hit_points = 0
>>> revive(gary)
>>> print_pokemon(gary)
Pokemon: Gyarados (130) HP: 41/83
>>> gary.hit_points = 20
>>> revive(gary)
This Gyarados is not fainted.
>>> print_pokemon(gary)
Pokemon: Gyarados (130) HP: 20/83 Tester.Part 2, 2 points: Let's combine our expertise of lists and Pokemon and write a function that returns a list of fainted pokemon from a list of multiple pokemon, >>> gary = create_pokemon('Gyarados', 130, ['Water', 'Flying'], 83)
>>> gary.hit_points = 0
>>> vandal = create_pokemon('Jigglypuff', 39, ['Normal', 'Fairy'], 44)
>>> pyro = create_pokemon('Flareon', 136, ['Fire'], 77)
>>> schiggy = create_pokemon('Squirtle', 7, ['Water'], 56)
>>> pyro.hit_points = 0
>>> pokemon = [gary, vandal, schiggy, pyro]
>>> fainted = get_fainted(pokemon)
>>> for p in fainted:
print_pokemon(p)
Pokemon: Gyarados (130) HP: 0/83
Pokemon: Flareon (136) HP: 0/77 Tester.Submitting your Project: Make sure all your code is in a file labelled with your user name (everything before the @ in your school email address) followed by |