Challenge 1
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercisesExercise 1 — Tournament Challenge - Team Roster
Welcome to the Codémon Tournament! You're preparing for the big event. Loop through your team of Codémon and display each one with its position number (starting from 1).
team = ["Aquachu", "Pyrochu", "Florachu", "Rockachu"]
# Display each Codémon with its positionExercise 2 — Tournament Challenge - Battle Endurance
First round of the tournament! Your Codémon must endure multiple attacks. - Use a while loop to simulate battle rounds. Each round, your Codémon loses 15 health points. - Display the health after each round until it reaches 0 or below.
health = 100
round_number = 1
# Simulate battle roundsExercise 3 — Tournament Challenge - Finding the Legendary
You need to search through opponents to find the legendary Codémon to ban him from playing! - Loop through the list of opponents - Display each opponent you encounter - When you find "Legendary", display a special message and stop searching using
opponents = ["Codemon A", "Codemon B", "Legendary", "Codemon C", "Codemon D"]
# Search through opponentsExercise 4 — Tournament Challenge - Elite Fighters Only
Semi-finals! Only Codémon with high power levels can compete. - Loop through the power levels - Only display Codémon with power level 70 or higher - Skip the others
codemon_names = ["Aquachu", "Pyrochu", "Florachu", "Rockachu", "Zap"]
power_levels = [65, 80, 55, 75, 90]
# Display only elite fighters (power >= 70)