Variables & Data Types
- β¨ Python variables spring into existence when you assign them. and can change type at runtime. β
- π Python variables are created when you are first assigned a value β they reference objects and Python is dynamically typed, so a name can refer to different types over time. β»οΈ
- π§ Use clear, descriptive names (snake_case by convention), do not start identifiers with digits, and avoid reserved keywords. π«
- π Use type(value) to inspect a valueβs type.
- You can assign multiple variables in one line (e.g., x, y = 1, 2). By convention, constants are written in ALL_CAPS. π£
quantity = 12 # intunit_price = 50.00 # floatfruit = "Apple" # stringin_stock = True # boolScreenshot of Python code showing variable assignments and printing their types.

Complete Code :
quantity = 12 # intunit_price = 50.00 # floatfruit = "Apple" # stringin_stock = True # bool
print(type(quantity)) # <class 'int'>print(type(unit_price)) # <class 'float'>print(type(fruit)) # <class 'str'>print(type(in_stock)) # <class 'bool'>π Letβs compare it with other programming languages.
Variable Declaration in Other Languages
Section titled βVariable Declaration in Other LanguagesβIn C# and JavaScript you must declare a type or use let/const:
C# Example:
int count = 1;string name = "Banky";JavaScript Example:
let count = 1;const name = "Banky";π Naming Conventions Comparison
Section titled βπ Naming Conventions Comparisonβπ Click to expand: Comparison of common naming conventions
Using the example: βmaximum retry countβ
| Convention | Example | Typical Usage |
|---|---|---|
| snake_case | max_retry_count | Variables, functions (Python, Ruby) |
| camelCase | maxRetryCount | Variables, methods (JS, C#, Java) |
| PascalCase | MaxRetryCount | Classes, enums, types |
| ALL_CAPS | MAX_RETRY_COUNT | Constants, environment variables |
π Key takeaway:
Naming conventions are not cosmetic β they communicate intent to other developers.