01 Additional Matrials
01 Additional Matrials
Memory Model
Additional Materials
Python Arithmetic Operators
Python Operators
• Python divides the operators in the following groups:
• Arithmetic operators: +, -, …
• Assignment operators: =, +=, -=, …
• Comparison operators: ==, >=, <=, > …
• Logical operators: and, or, not, …
• Identity operators: is, is not
• Membership operators, in
• Bitwise operators: &, |, ^, ~, <<. >>
https://www.w3schools.com/python/python_operators.asp
Python Operators
Arithmetic & Assignment
• balance = 1000
• deposit = 100
• balance = balance + deposit
•
• balance += deposit
•
Variable Names
(RealPython)
• Python variable names can include letters, digits, and underscores but can’t
start with a digit.
https://en.wikipedia.org/wiki/Naming_convention_(programming)
Some coding styles
https://www.threads.net/@donachodiary/post/C9PbGIuPtNV/media
https://peps.python.org/pep-0008/
Some coding styles
https://peps.python.org/pep-0008/
Good Variable Names
• Avoid, 1, 0, l, O,
• ASCII compatibility
• ASCII stands for American
Standard Code for
Information Interchange.
• * Character Encoding
• UTF-8, Unicode, …
FYI, not python
https://dev.to/mohitsinghchauhan/clean-code-101-variable-naming-conventions-part-1-1c1a
FYI, not python
FYI, not python
https://dev.to/mohitsinghchauhan/clean-code-101-variable-naming-conventions-part-1-1c1a
FYI, not python
https://codingwithroby.substack.com/p/clean-code-the-art-of-clean-naming
Python Literals
• Literals in Python are xed values written directly in the code that represent
constant data.
• Syntax Errors
• print(“abc)
• primp(“abc”)
• 1/0
• Bugs: A software bug is a design defect (bug) in computer software.
• Handling errors: e.g., timeout, internet connection, … 1/0 in calculator?
Memory Model
• Python
• built-in types, functions, literals
• built-in modules
• The term library is simply a generic term for a bunch of code that was
designed with the aim of being usable by many applications.