Variables
Nerd Cafe
What is a Variable?
1. Declaring Variables
x = 5
name = "Mr Nerd"
price = 19.99
is_active = TruePractical Notes:
2. Variable Naming Rules (Very Important in ML Projects)
# Valid
data = [1, 2, 3]
learning_rate = 0.01
model_name = "LinearRegression"
# Invalid
# 1model = "wrong" ❌ Starts with a number
# learning-rate = 0.01 ❌ Hyphen not allowedBest Practices (PEP8 Style Guide for ML Code):
3. Updating Variables
Shortcuts:
4. Data Types in Machine Learning
5. Practical Use in ML:
6. Multiple Assignments
7. Constants (Not Built-in, But You Can Use UPPERCASE)
8. Type Checking (Important in Debugging ML Code)
9. Variable Scope (Global vs Local)
Output:
10. Dynamic Typing
11. Example in a Mini Machine Learning Context
12. Using Variables in NumPy (Essential for ML)
Output:
Summary Table
Feature
Example
Notes
Keywords
Last updated