2. Variables & Datatypes
What are Variables?
Let's visualize variables like this. Imagine a box with nothing inside of it. That's what a variable is; A container to store data.
Adding something inside the box assigns the box with a particular item. In the same way, when you add a datatype into a variable, you assign it with that value.
What are Datatypes?
The different types of values stored in a variable are known as datatypes. Datatypes are an essential part of programming, no matter how advanced of a programmer you are.
The Fundamental Datatypes
12
Integers are considered to be any whole number.
3.1415
Floats are any numbers that contain decimal values.
"Hello"
Strings are anything in double quotation marks.
True
Booleans are a True or False value.
How do you Create a Variable?
First, create a name for your variable. Remember that a variable name cannot have any spaces and cannot begin with a capital letter. You can add underscores between words for variable names.
my_name
Next, add an equal sign after the name of the variable.
my_name =
Finally, assign a value after the equal sign to store a value in the variable. You can assign any of the data types listed above.
my_name = "Jake"
Where do you use Variables?
Variables are the foundations of any program. From beginners to software engineers, everyone will use variables no matter how experienced you are.