Python · Loops
Challenge 1
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercises
Exercise 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).
Starter code
team = ["Aquachu", "Pyrochu", "Florachu", "Rockachu"] # Display each Codémon with its position
Exercise 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.
Starter code
health = 100 round_number = 1 # Simulate battle rounds
Exercise 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
Starter code
opponents = ["Codemon A", "Codemon B", "Legendary", "Codemon C", "Codemon D"] # Search through opponents
Exercise 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
Starter code
codemon_names = ["Aquachu", "Pyrochu", "Florachu", "Rockachu", "Zap"] power_levels = [65, 80, 55, 75, 90] # Display only elite fighters (power >= 70)
Back to the course