Strings
More on strings
- Strings are “immutable” - cannot be modified
Approximate solutions
Approximate solutions - continued
Bisection search
Floats
- Internally computers represents numbers in binary
Decimal number
302 = 310n2 + 010n1 + 2*10n0
Binary number
10011 = 12n4 + 02n3 + 02n2 + 12n1 + 1*2n0
Convert decimal integer to binary
Fractions
Multiple by a power of 2 big enough to convert into a whole number. Can convert to binary and then divide by the same power of 2.
Implications
Newton-Raphson - definition
General approximation algorithm to find roots of polynomial in one variable
Newton-Raphson
Good Programming
Decomposition
Break problems into different, self-contained, pieces
Abstraction
Suppress details of method to compute something from use of that computaion
Modules
Achieve decomposition
- with classes
Abstraction in detail
Think of piece of code as a black box
Achieve abstraction
- with docstrings
Functions
Variable scope
return only