Challenge

The full text of this chapter, to read or revisit. To practise, do the exercises.

▶ Do the exercises

Exercise 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

Starter code
egg1 = ("Pyrochu", 45, "Fire") # Code here

Exercise 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.

Starter code
base_info = ("Pyrochu", 45, "Fire") bonus_stats = (150, 60) # Code here

Exercise 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

Starter code
egg2 = ("Aquachu", 38, "Water") egg3 = ("Florachu", 52, "Plant") # Code here

Exercise 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.

Starter code
my_collection = [("Pyrochu", 45, "Fire"), ("Florachu", 52, "Plant")] # Code here
Back to the course