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!
التالي · الدرس 4 من 26
Basic Arithmetic Operations
قراءة 1 دقيقة
أنهيت 3 من 26 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

