Types of Variables
VARIABLES
what are variables?
- Variables are nothing but a name given to a data.
- It is also a reference to the data location in memory (RAM).
- I would even say, it is a pointer to that memory location.
- variables are executed in order of Top --> Bottom.
Types of Variables
- Strings
- Numbers
- Decimal
- Boolean
- List
Rules for Variables Names
- it can only have alphabet, alphabet+number and special character like underscore.
- should be meaningful.
- ex:
- lowercase alphabet => a-z
- uppercase alphabet => A-Z
- number => 0-9
- underscore => _
Example
- a1 = 10 ✅
- cust_name = ‘James’ ✅
- cust-name = ‘James’ ❌
- cust name - ‘James’ ❌
String
- title = “John smith”
Numbers
**Different Print statements **
print(f"variable")
used for variables places inside curly brackets {variable}
>>> title = "John Smith"
>>> print(f"{title}")
John Smith
print(“string”)
>>> print("john smith")
john smith
>>>