Chapter 1: The Fundamentals
Chapter 1: The Fundamentals#
This chapter contains the basics of Python covered in the MT2000 workshops that we will build upon in this module. Take the first week to refresh this material and use this chapter as a reference as you work through the rest of the module.
- Python & Jupyter
- Variables
- Reassigning variables
- Viewing variables
- Variable names
- Optional: Multiple labels for one object
- More mathematical commands via Numpy
- Other modules
- Errors
- Printing output to the screen
- Optional: Formatted strings
- For loops
- Ranges
- Looping over lists
- Nested
for
loops - Nested
for
loops - Functions
- Fruitful functions
- Multiple parameters
- Multiple return values
- Invisible variables
- Optional Aside 1: Member functions
- Optional Aside 2: Duck typing
- Optional Aside 3: Default Arguments
- Conditions and basic
if
statements - Relational and logical operators
- Divisibility and the modulo operator
- Logical Operators
If-else
statementsElif
statements- Conditional
return
statements - Aside: Patterns
- While loops
- Infinite loops
Break
ing out of loops- Lists
- Nested Lists
- Tuples
- Arrays
- Creating Arrays
- Diagonal arrays
- Working with
arrays
- List slicing
- Array slicing
- Assignment with arrays and lists
- Floating point numbers
- Precision and the machine epsilon
- Binary representations
- Comparing floats
- Overflow and underflow
- Infinity and NaN
- Data structures
- Sets
- Dicts
- Types
- Conversion between types
- Input and files
CSV
filesNumpy
input and output- Matplotlib
- Basic 2D plots
- 3D surface plots
- Contour plots
- Vector fields
- Annotations
- Saving plots
- Animated plots
- Markdown
- Optional: writing maths using \(\LaTeX\)
- SymPy
- Creating symbols
- Expressions and substitution
- Evaluation
- Exact values
- Manipulating expressions
- Solving equations
- Differentiation
- Integration
- Plotting
- Interactivity