Challenge 1

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

▶ Do the exercises

Exercise 1 — Trading Post - New Arrivals

You just opened your Trading Post! Trainers are bringing their Codémon to sell. Three trainers arrive: - First trainer brings "Aquachu" - Second trainer brings "Rockachu" - Third trainer brings "Florachu" Add Codémon one by one to your inventory and then print it.

Starter code
inventory = ["Pyrochu"] # Code here

Exercise 2 — Trading Post - Making Sales

Business is good! Customers are buying your Codémon. Three customers arrive: - First customer buys "Aquachu" - remove it from inventory - Second customer is a gambler! He wants the last Codémon in your list - Third customer buys "Rockachu" - remove it from inventory Display your inventory at the end.

Starter code
inventory = ["Pyrochu", "Aquachu", "Rockachu", "Florachu"] # Code here

Exercise 3 — Trading Post - Big Delivery

Your inventory is running low! A truck arrives with a big delivery. The delivery contains: ["Zap", "Aquachu", "Florachu", "Pyrochu"] - Add all the Codémon from the delivery at once to your inventory. - It's the end of your day! Count how many Codémon you have in total and store it in total.

Starter code
inventory = ["Rockachu"] delivery = ["Zap", "Aquachu", "Florachu", "Pyrochu"] # Code here

Exercise 4 — Trading Post - Customer Request

A customer walks in looking for a specific Codémon! "Hello! I'm looking for a Zap. Do you have one?" - Check if you have "Zap" in your inventory. - If you have it, remove it from your inventory (he buys it). - If you don't have it, he says: "No problem! I'll take the Codémon you've had for the longest time. I want to make it happy again!" - Remove the first Codémon from your inventory and store it in oldest_codemon.

Starter code
inventory = ["Rockachu", "Zap", "Aquachu", "Florachu", "Pyrochu"] # Code here

Exercise 5 — Trading Post - Jeff Bezochu's Offer

A fancy businessman walks into your Trading Post! "Hello! I'm Jeff Bezochu, owner of Amazorb. I want to buy ALL your Codémon stock. Name your price!" -This is a once-in-a-lifetime opportunity! Remove all Codémon from your inventory at once. - Display your inventory after the sale to confirm it's empty.

Starter code
inventory = ["Rockachu", "Aquachu", "Florachu", "Pyrochu"] # Code here
Back to the course