tutorial |
---|
In programming, we use variables like boxes (or containers) to store different kinds of information. Here's how to create a variable:
name = "Daniel"
In this example, name
is the variable, acting like a box to store the value "Daniel"
. Inside this 'box', we're storing the value "Daniel"
, and we can use name
to refer to it later. When naming your variables, you can choose almost any name, but it must begin with a letter or an underscore (_
). It's helpful to pick a name that describes what's inside the 'box' so you can easily understand what it represents later on.
-
Declare a new variable with the string value
"Yellow"
and print the value to the console. -
Then, print its value on the console using
print(name)
.
-
The name of the variable can be whatever you want, but the value inside has to be the string "Yellow".
-
If you need further explanation on what strings are and how they work in Python, you can watch this clip: https://youtube.com/clip/UgkxyQ_JLmgSUL4l25c8Ly7cCRvk1Gm-EchU (
ctrl + click
on the link to open the video)