Main Notes
- Philosophy: “There should be one obvious way to do one thing.”
- Zen of Programming:
- Beautiful is better than Ugly
- Explicit is better than Implict
- Simple is better than Complex
- Complex is better than Complicated
- Readability Counts
- Multi-Paradigm Language
Variables
- Variables hold value by reference, and are called “names” instead of variables.
- Variables are dynamic, meaning the same variable can be set to different types.
- Comparisons are done with values but can be done with references as well.
- Variable Unpacking: multiple variables can be set in one expression.
Data Structures
def foo(a,b,c):
baz = a + b + c
print(baz)
bar = [1,2,3]
foo(*bar) #prints 6
The tuple bar
is unpacked to the function foo
as bar
by itself would give a type error.
(GeeksforGeeks: Packing and Unpacking Arguments For Python)
Functions
- All functions return a value.
Syntax
- Python just has one way to write comments, with the
#
character preceding the comment, not working in strings. - Blocks are delimited by white space characters instead of parenthesis.
- Quote (‘) and double quote (“) can be used interchangeably, triple quotes denotes multi-line strings.
(Wikipedia: Python (programming language))
(Microsoft | Vistual Studio Docs: Python In Visual Studio)