Variable
Variable are:
- Storage location that have a name
- Storage location that have a name
fruit = 'apple'
fruit = 'orange'
* Pick variable name that represent data that variable will hold
Valid Variable Names
- Case sensitive. (Case matters!)
- Fruit and fruit are different variable
- Must start with a letter.
- Can contain numbers.
- Underscores allowed in variable names
- Not allowed: + -
first3letters = 'ABC' first_three_letters = 'ABC' firstThreeLetters. = 'ABC'* Pick variable name that represent data that variable will hold
Reserved Keywords
FalsedefifraiseNonedelimportreturnTrueelifintryandelseiswhileasexceptlambdawithassertfinallynonlocalyieldbreakfornotclassfromorcontinueglobalpass*** Function name also not recommend
Example
![]()
*** Function name also not recommend
Data Type
Basic Data Types
- Numeric
- Integer
- Floating point
- Boolean
- String
Composite Data Types
- List
- Tuple
- Dictionary
- Set
Numbers
- Use numbers directly in your source code
- Do not use quotation marks as they are for strings.
integer = 42
float = 4.2
a = b = c = d = 0.0
* Pick variable name that represent data that variable will hold
Example
Boolean
A Boolean variable can reference one of two values: True or False. Boolean variables are commonly used as flags, which indicate whether specific conditions exist.
hungry = True
leepy = False
Example
String
Strings
- Represent text
- Surrounded by quotes
fruit = 'apple'
fruit = “apple”
string1, string2, string3 = '', 'Knife', 'Hammer Dance'
* Strings are start with ' or " and end with 'or "
Using Quotes within Strings
sentence = 'She said, "That is a great tasting apple!" '
sentence = " That's a great tasting apple! "
double = "She said, \"That 's a great tasting apple! \" "
single = 'She said, "That\'s a great tasting apple! " '




