Python Unleashed: Unlock the Potential of Programming — Variables

Woody
5 min readJan 14, 2023

Chapter 3

Photo by Christopher Gower on Unsplash

Intro to Variables

I was conscious in the previous chapter that I wanted to go into a lot of detail on Data Types, so instead of making it an even longer read I split variables into the following chapter. The two topics go hand in hand and I will go into more detail below.

In programming, a variable is a way to store and manipulate data in a program. Variables are used to hold values that can change during the execution of a program. These values can be of different types, such as numbers, strings, lists, etc.

In Python, variables are created when a value is assigned to a name. The assignment operator = is used to assign a value to a variable. For example, the following code creates a variable x and assigns the value 5 to it:

x = 5

You can also assign a value of a different type to the same variable later on:

x = 5
x = "Hello, World!"

In Python, variables do not have to be declared before they are used, and their type is determined by the value that is assigned to them.

You can also assign multiple variables in one line, like this:

x, y, z = 1, 2, 3

--

--

Woody
Woody

Written by Woody

Developer and technology enthusiast new to Medium writing.

No responses yet