- Several ways to use the python interpreter
- Interactively
- Quick testing
- Exiting
exit()
,quit()
, orctrl + D
- Run the code
- For larger chunks of code
python filename.py
orpython3 filename.py
- Using an IDE
- For large projects
- Interactively
- Every entity is an object
- Every object has
- A type
- Some value
- Every object has
- Basic data types
- Numbers
int
,float
,complex
- Boolean
bool
- String
str
- Numbers
- Use
type()
to check the type of the object
- Arithmetic operators
- Addition
+
- Subtraction
-
- Multiplication
*
- Division
/
- Floor division
//
- Modulo
%
- Exponential
**
- Addition
- Operator precedence
()
,**
,* // / %
,+ -
- Overloaded operators
- Concatenation
+
- Repeat however many times
*
- Concatenation
- Variables is a name or label that points to an object instance in memory
- Assignment statement
variable_name = value
- Different variables can point to the same object
- Expressions
- Produce a value
- Statements
- Instruction that a computer can execute
- May not produce a value
- Keywords
- ...,
nonlocal
, ...
- ...,
- Conventions
- Consists of letters, digits, or underscores
- Must start with a letter or an underscore
- Cannot be a reserved keyword
- Use lowercase + underscores