Variables
There are values that can change
Example: temperature in the room every ten seconds
Fixed Variables:
x = 4
y = 6
print(x+y)
Output:
10
Variable Naming Convention
We have 3 temperature probes
- Outside
- Inside
- In Water
Naming System 1:
- tempinside
- tempoutside
- tempwater
Naming System 2:
- temp_1
- temp_2
- temp_3
Naming System 3:
- temp_inside
- temp_outside
- temp_water
Naming System 4:
- temp_in
- temp_out
- temp_h2o
Rules of Variables:
- Variables can’t start with a number
- No spaces in variables (Use underscores (_) )
-
No using special characters
E.g: @, !, #, etc.
- It is possible but you should never use python commands as variable names
Numerical Variables
Name | Function | Description | Example |
---|---|---|---|
Integer | int | Positive Whole Numbers | 10 |
Float | float | Decimal Numbers | 8.37 |
String | str | A collection of characters | “John” |
Boolean | bool | True/False | True |