

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Loops
incomplete
2: Loops Practice
incomplete
3: Loops Practice
incomplete
4: Loop Review
incomplete
5: Loop Review
incomplete
6: Whitespace in Python
incomplete
7: Range Continued
incomplete
8: Sum Game
incomplete
9: Sum Game 2
incomplete
10: While
incomplete
11: Continue Statement
incomplete
12: Break Statement
incomplete
13: Match Countdown
incomplete
14: Experience Points
incomplete
15: Meditate
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Adventurers need experience points (XP) to level up and become stronger. We want to show the total XP a player has gained given their current level.
Each character starts with 0 XP at level 1. To reach the next level, they need to accumulate additional XP equal to their current level times 5.
For example:
At level 1, XP is 0.
To reach level 2, we need 5 XP (1 * 5) added to the current XP so far (0).
At level 2, XP is 5.
To reach level 3, we need 10 XP (2 * 5) added to the current XP so far (5).
At level 3, XP is 15.
To reach level 4, we need 15 XP (3 * 5) added to the current XP so far (15).
And so on...
To summarize the calculation in a table:
| Level | XP so far | XP for next level |
|---|---|---|
| 1 | 0 | 5 |
| 2 | 5 | 10 |
| 3 | 15 | 15 |
| 4 | 30 | 20 |
Complete the calculate_experience_points function.
It accepts a level (integer) and returns the total XP a player has gained so far.