Variables and Data Types in Python


  1. What are Variables?

→ In Programming a Variable is a storage location identified by a memory address paired with an associated symbolic name, which contains some known or unknown quantity referred to as a value. In simple terms, You can think of it as a box where we can store a certain value of any type.

  1. Variables with Python

→ With Python,Variables are extremely easy to use. You simply name a variable and use a assignment operator i.e “=” to give it a certain value, In our last example We used the program

print(“Hello World!”)

It prints the Word “Hello World” into the screen,

We will now write the same program with python using variables, I want you to do this along with me,type the following code in your IDE.

mes=”Hello World!”


It should print out the same output

What we did here was first we made a variable called ‘mes’, In python you can simply make a variable by mentioning its name. After making the variable we simply gave it a value of “Hello World!”. This makes our job as a programmer a whole lot easier because instead of putting the value we can simply attach the variable, Variables are very important in programming. Variables can store all sorts of data types, not just strings.

  1. Creating a simple message using variables in python.

We will now create a simple message in python using variables.Using the information provided above, I would like to make two variables and name them, Name and Age and give them any value of your choosing.I’ll make the name Jack and age 25 and make message lines below as shown in the image.

Run the program, Output like this should show up:

Now I want you to go and change the name to “Dennis”, with variables it’s very easy as you simply change the variable’s value, however imagine if there was no variable we would have to go individually and change the value, This is one of examples on how important variables are.

One Comment on “Variables and Data Types in Python”

  1. I’ve read some just right stuff here.
    Certainly worth bookmarking for
    revisiting. I surprise how much effort you place to
    make such a excellent informative website.

Leave a Reply

Your email address will not be published. Required fields are marked *