Challenge 2
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercisesExercise 1 — First Codémon - Starting Your Collection
You're starting your Codémon journey! You want to buy your first 3 Codémon.
You find a shop selling exactly 3 Codémon with these prices: [150, 200, 175]
You have 600 coins saved up.
- Calculate the total cost and store it in total_cost.
- If you have enough money, buy all 3 Codémon! Store their names in my_team and reduce your coins.
prices = [150, 200, 175]
codemon_names = ["Pyrochu", "Aquachu", "Florachu"]
coins = 600
# Code hereExercise 2 — First Codémon - Choosing Your Leader
Now that you have your team, you need to organize it!
Your Codémon power levels: [45, 62, 38]
- Find your team leader (the strongest Codémon) and store its power in leader_power
- Find which Codémon needs more training (the weakest one) and store its power in needs_training
power_levels = [45, 62, 38]
# Code hereExercise 3 — First Codémon - Your First Battle
You meet a friend who also just started their journey! You both decide to battle with all your Codémon at the same time. Team with better average wins!
- Calculate the average power of your team and store it in your_average
- Calculate the average power of your friend's team and store it in friend_average
- Display which team won: "You win!" or "Friend wins!"
your_team = [45, 62, 38]
friend_team = [50, 48, 55]
# Code here