Variables and Types
Names bound to values with defined operations.
Do this: Read the concept below, then try the quiz or activity.
Lesson 2 of 20
5%
Concept
A variable stores a value. Types (number, string, boolean, etc.) determine valid operations and memory representation. Prefer clear names and minimal scope.
Try it
Create a variable for item price and tax rate; compute total and print it.
Type Basics
1 / 3Number
(Click to flip)Quantities for arithmetic operations
(Click to flip back)Code Tracer
Step through and watch price, tax_rate, and total.
Step through the code and watch the variables change.
1. price = 102. tax_rate = 0.083. total = price * (1 + tax_rate)4. print(total)
Variables
- —