Challenge
The full text of this chapter, to read or revisit. To practise, do the exercises.
▶ Do the exercisesExercise 1 — Codémon Eggs - First Discovery
Prof Pi just gave you 3 mysterious Codémon eggs! Each egg is a tuple: (name, power, type)
- Unpack the first egg into three variables: name, power, and type
- Display each variable
egg1 = ("Pyrochu", 45, "Fire")
# Code hereExercise 2 — Codémon Eggs - Hatching
Your first egg hatched! The Codémon needs a complete profile.
- Combine both tuples to create a complete profile and store it in complete_profile
- Display the complete profile.
base_info = ("Pyrochu", 45, "Fire")
bonus_stats = (150, 60)
# Code hereExercise 3 — Codémon Eggs - Choosing the Best
Now, you look at the 2 others eggs..
- Unpack both eggs and compare their power levels.
- Keep the strongest egg (higher power) in strongest_egg
- Display the strongest egg
egg2 = ("Aquachu", 38, "Water")
egg3 = ("Florachu", 52, "Plant")
# Code hereExercise 4 — Codémon Eggs - Power Boost
The strongest egg hatched! Your Codémon gained experience and its power increased by 10! - Unpack Florachu, create a new tuple with power increased by 10. - Replace the old Florachu tuple in your collection at index 1. - Display your updated collection.
my_collection = [("Pyrochu", 45, "Fire"), ("Florachu", 52, "Plant")]
# Code here