Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Storing Data in Variables | Variables and Types
Introduction to Python Video Course
course content

Course Content

Introduction to Python Video Course

Introduction to Python Video Course

1. Getting Started
2. Variables and Types
3. Conditional Statements
4. Other Data Types
5. Loops
6. Functions

Storing Data in Variables

Brilliant work mastering data types! Next, we'll explore how to store data inside variables, much like organizing your groceries into the right bins. This makes your data easy to access and manipulate — key to any efficient coding project.

Watch Alex as he demonstrates how to store data in variables:

Let's put this into practice. Here, we're assigning various types of data to variables, each representing different aspects of a grocery item.

12345678910
# Storing different types of data in variables item_name = "Banana" item_price = 0.50 item_quantity = 100 in_stock = True print("Item:", item_name) print("Price: $", item_price) print("Quantity:", item_quantity) print("In stock:", in_stock)
copy

This example shows how easily you can access and display the data once it's stored in variables. Notice how each variable type (string, float, integer, boolean) serves a specific purpose in our grocery analogy.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 2
toggle bottom row

Storing Data in Variables

Brilliant work mastering data types! Next, we'll explore how to store data inside variables, much like organizing your groceries into the right bins. This makes your data easy to access and manipulate — key to any efficient coding project.

Watch Alex as he demonstrates how to store data in variables:

Let's put this into practice. Here, we're assigning various types of data to variables, each representing different aspects of a grocery item.

12345678910
# Storing different types of data in variables item_name = "Banana" item_price = 0.50 item_quantity = 100 in_stock = True print("Item:", item_name) print("Price: $", item_price) print("Quantity:", item_quantity) print("In stock:", in_stock)
copy

This example shows how easily you can access and display the data once it's stored in variables. Notice how each variable type (string, float, integer, boolean) serves a specific purpose in our grocery analogy.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 2
toggle bottom row

Storing Data in Variables

Brilliant work mastering data types! Next, we'll explore how to store data inside variables, much like organizing your groceries into the right bins. This makes your data easy to access and manipulate — key to any efficient coding project.

Watch Alex as he demonstrates how to store data in variables:

Let's put this into practice. Here, we're assigning various types of data to variables, each representing different aspects of a grocery item.

12345678910
# Storing different types of data in variables item_name = "Banana" item_price = 0.50 item_quantity = 100 in_stock = True print("Item:", item_name) print("Price: $", item_price) print("Quantity:", item_quantity) print("In stock:", in_stock)
copy

This example shows how easily you can access and display the data once it's stored in variables. Notice how each variable type (string, float, integer, boolean) serves a specific purpose in our grocery analogy.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Brilliant work mastering data types! Next, we'll explore how to store data inside variables, much like organizing your groceries into the right bins. This makes your data easy to access and manipulate — key to any efficient coding project.

Watch Alex as he demonstrates how to store data in variables:

Let's put this into practice. Here, we're assigning various types of data to variables, each representing different aspects of a grocery item.

12345678910
# Storing different types of data in variables item_name = "Banana" item_price = 0.50 item_quantity = 100 in_stock = True print("Item:", item_name) print("Price: $", item_price) print("Quantity:", item_quantity) print("In stock:", in_stock)
copy

This example shows how easily you can access and display the data once it's stored in variables. Notice how each variable type (string, float, integer, boolean) serves a specific purpose in our grocery analogy.

Task

Now it's your turn to take the reins.

Define variables for another grocery item, "Eggs", assign appropriate values reflecting the item's price, quantity, and stock status, then print these details.

We know that the price of each egg is $3.99, and we have 120 eggs in stock.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 2
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt