Variable Exercises

Test your understanding of variables with these exercises:

Exercise 1: Create a Variable

Create a variable named my_name and assign your name to it. Then print the variable.

Python
# Your code here
my_name = "Your Name"
print(my_name)

Exercise 2: Multiple Variables

Assign the values 5, 10, and 15 to variables a, b, and c in one line, then print them.

Python
# Your code here
a, b, c = 5, 10, 15
print(a, b, c)

Exercise 3: Modify a Global Variable

Modify a global variable inside a function using the global keyword. Create a global variable x, set it to 50, then write a function that changes it to 100.

Python
# Your code here
x = 50

def change_global():
    global x
    x = 100

change_global()
print(x)  # Output should be 100