Skip to content

Day 3: Python Variables

Creating Variables

In Python, a variable is a named location in memory that stores a value. It is used to store and manipulate data within a program. To create a variable in Python, you need to specify the variable's name and assign its value using the assignment operator, which is the equal sign. Here's an example:

x = 10
y = "Hello"

Assign Multiple Variables

You can also assign values to multiple variables simultaneously. In the given example, 'x' is assigned the value 10, 'y' is assigned 20, and 'z' is assigned 30.

x, y, z = 10, 20, 30

Change the Assigned Value

It's possible to assign a value to a variable and then change it later. In the provided example, 'x' is first assigned a value of 10, which is then changed to 20.

x = 10
x = 20

Delete a Variable

The 'del' keyword can be used to delete a variable, which releases the memory it occupied for other purposes.

del x

Learn More

Want to learn more about Python for Machine Learning? Check out the full course HERE.


Need help mastering Machine Learning?

Don't just follow along — join me! Get exclusive access to me, your instructor, who can help answer any of your questions. Additionally, get access to a private learning group where you can learn together and support each other on your AI journey.