Python Variables Explained - Store Data in Code

Published: 20 May 2026
on channel: Arohas Code Lab
4
1

Build your first reusable Python programs with variables. We store values once, reuse their names, calculate totals, and avoid the common reassignment surprise where old output does not change.

#python #learnpython #pythonbeginners #codingtutorial #programmingbasics

⏱ Chapters:
0:00 Intro — Arohas Code Lab
0:03 One Recipe Amount, Many Steps
0:22 A Label Finds a Stored Value
0:37 Store a Name, Then Read It
0:57 Prices and Counts Become Reusable
1:15 Changing a Variable Affects Future Reads
1:32 Store Changing Facts, Reuse Labels

Challenge
Create a function that receives an item price and a quantity, then returns the total cost.

Entry point:
```python
def total_cost(price, quantity):
return price * quantity
```

Expected behavior:
`total_cost(5, 3)` returns `15`
`total_cost(8, 2)` returns `16`

Worked solution:
```python
def total_cost(price, quantity):
total = price * quantity # Multiply the two input values
return total # Send the calculated result back to the caller

print(total_cost(5, 3)) # Expected output: 15
print(total_cost(8, 2)) # Expected output: 16
```

Explanation: the price and quantity are changing facts, so the function reads their names and calculates the result without hard-coding one shopping trip.


On this page of the site you can watch the video online Python Variables Explained - Store Data in Code with a duration of hours minute second in good quality, which was uploaded by the user Arohas Code Lab 20 May 2026, share the link with friends and acquaintances, this video has already been watched 4 times on youtube and it was liked by 1 viewers. Enjoy your viewing!