Variables and Data Types
In programming, a variable is a container that holds a value. Think of it as a labeled box where you store information you'll use later.
Creating Variables
Let's create some variables for financial data:
The = sign doesn't mean "equals" in the mathematical sense - it means "assign the value on the right to the variable on the left."
Variable Naming Rules
Variable names in Python:
- Can contain letters, numbers, and underscores
- Must start with a letter or underscore (not a number)
- Are case-sensitive (
stockPriceandstockpriceare different) - Cannot use reserved words like
if,for,while
Good vs Bad Variable Names
Data Types in Python
Python automatically determines what type of data you're storing. Understanding these types is crucial for financial work.
Integers (int) - Whole numbers
Floating-Point Numbers (float) - Decimals
Strings (str) - Text
Booleans (bool) - True/False
Practice Exercise
Key Takeaways
- Variables store data that you can use later
- Use descriptive names to make code readable
- Integers are whole numbers (shares, years)
- Floats are decimals (prices, returns)
- Strings are text (ticker symbols, company names)
- Booleans are True/False values (yes/no conditions)
Next, we'll learn how to perform calculations with these variables using arithmetic operations!
Up next · Lesson 4 of 26
Basic Arithmetic Operations
1 min read
3 of 26 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

