Python Review
{Review Notes made with W3 Schools}
Syntax
- Indention is important to indicate blocks of codes in Python
- Comments:
Variables
- There's no command for declaring a variable, so you can just do x=9
- Variables are created whenever you assign a value to it meaning you don't need to declare it as a type & you're free to change the type after its been created
- If you want to specify the type, you can cast it
- If you want to find the data type of the variable, you can print it with type()
- String variables can be declared with single or double quotes
Names
- Variable names must start with a letter or underscore - cannot start with numbers
- Variable names are case sensitive (hello, HELLO, Hello)
- Cannot be a python keyword
- Variable name can only contain alpha numeric characters and underscores (A-z, 0-9, and _ )
- Variable naming conversions
Multiple Values
- You can assign multiple variables in one line
- If you have a list, you can unpack it to extract the values into variables