Variables and Data Types

In Python, variables are used to store data that can be used and manipulated later in your program. Think of variables as labeled containers for your data.

What is a Variable?

A variable is a name that refers to a location in memory where a value is stored. In Python, you don't need to explicitly declare variables like in other programming languages, and they are created when you assign a value to them using the = sign.

Data Types in Python

Variables in Python can store different types of data. Here are some of the most common data types:

Example: Variables

name = "Alice"
age = 25
is_student = True

Explanation

In this example, we created three variables: name (a string), age (an integer), and is_student (a boolean). Python automatically understands the type of data you're working with based on the value you assign to the variable.

Exercise

Create variables that store your name, age, and whether you are currently learning Python (True or False).

your_name = "Your Name"
your_age = Your Age
learning_python = True