Challenge

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

▶ Do the exercises

Exercise 1 — Zap's Basic Stats

Let's create a profile for Zap, our mascot! Create three variables: - codemon_name containing the string "Zap" - hp (health point) containing the integer 100 - xp (experience point) containing the integer 750 Then print all three variables.

Starter code
# Code here

Exercise 2 — Computing Zap's Level

Now let's calculate Zap's level! - Create a variable level by dividing xp by 100 - Print level and its type - If level is not an integer already, cast it to an integer - Print it again with its type to see the difference.

Starter code
codemon_name = "Zap" hp = 100 xp = 750 # Code here

Exercise 3 — Is Zap Ready to Fight?

Let's complete Zap's profile! - Create a boolean variable is_ready_to_fight and set it to True - Print the complete profile: name, hp, xp, level, and battle readiness status.

Starter code
codemon_name = "Zap" hp = 100 xp = 750 level = int(xp / 100) # Code here
Back to the course