

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
click for more info
Not enough gems
Cost: 6 gems
1: Scope
incomplete
2: Global Scope
incomplete
3: Scope Quiz
incomplete
This lesson's interactive features are locked, please to keep using them
So far we've been working in the global scope. That means that when we define a variable or a function, that name is accessible in every other place in our program, even within other functions.
For example:
pi = 3.14
def get_area_of_circle(radius):
return pi * radius * radius
Because pi was declared in the parent "global" scope, it is usable within the get_area_of_circle() function.
Let's change how we are calculating our player's stats! The only thing we should need to define globally is the character level and then let our functions do the rest!
Declare the variable player_level at the top of the global scope and set it to 4.