Member-only story

Python Variables and Data Types

Rafay Syed
9 min readSep 5, 2019

--

What is a variable in Python? You can think of a variable as a container that stores some value. That value could be a number or a string, which is a sequence of characters. You can think of a variable as the mailbox and the value as the letter, as shown in the illustration below.

Photo by Arcbotics

The mailbox stores the letter, just as a variable stores the value. When you have a variable assigned to a value, that is known as a statement. An example of a statement is as follows:

age = 25

In the statement above, age is the variable name and 25 is the value that is stored in the variable. You can read the statement as “age is assigned to the value 25”.

The above was an example of how a variable can be assigned to a value, but what are the different types of values that variables can store, and how many? We will get to the “how many” part in the data structures section, but for now, we will focus on the types of variables that can be stored.

Naming Variables

Before we get to the fun part, I want to talk about naming conventions for variables. Here are some big no-no’s when it comes to naming variables:

  1. Variables cannot start with a number. For example, you can not have a variable called ‘2Pac’ or ‘21_Savage’. However, you can include numbers…

--

--

Rafay Syed
Rafay Syed

Written by Rafay Syed

Software Engineer at Salesforce and Lifelong Student

Responses (1)

Write a response