My First Variable
Create a variable called 'greeting' with the value "Hello" and display it on the screen.
Learn how to store data in variables. Variables are like labeled boxes where you can put information.
Python errors explainedA variable is a name that refers to a value stored in computer memory.
To create a variable, use the = sign:
name = "Alice"
age = 25
The variable name is on the left, and the value is on the right.
You can then use variables in print():
print(name) # Will display: Alice
print(age) # Will display: 25
Create a variable called 'greeting' with the value "Hello" and display it on the screen.
Create a variable called 'age' with the value 10 (a number, not text!) and display it. Note: Numbers don't need quotes!
Create two variables: - 'name' with your name - 'city' with your city Display both on separate lines.
Create a variable 'x' with value 5, then change it to 10, and display the result. The output should show only 10 (the final value).
Learn how to store data in variables. Variables are like labeled boxes where you can put information.
This lesson has 4 exercises.
No. The code is written and run in the browser.