Lesson 6: Bisection methods, Newton/Raphson, introduction to lists
Massachusetts Institute of Technology (OpenCoarseWare): Introduction to Computer Science and Programming
View the complete course at: http://ocw.mit.edu/6-00F08
Introduction to Computer Science & Programming Class Notes
Bisection methods, Newton/Raphson, introduction to lists
Speed of Convergence
f(guess = guess2 -x
f(guess) = 0
As discussed in lesson 5, the best method to find the answer for
differentiable functions is the Netwon/Ralphson Method.
guess i = guess i – f (guess i) / 2 guess i (the
letter i represents positive.)
Non-Scalar (Tuples & Strings) Also worded as immutable.
Lists are mutable.
Lists differ from strings in two ways one is that strings are immutable, the
other is that the value in lists need not be characters.
Lists can compromise of numbers, characters, strings, they can even contain
Examples of lists in Python:
Techs = [ 'MIT', 'Cal Tech' ] Ivys = [ 'Harvard', 'Yale', 'Brown'] Univs = [ ] The values in the brackets for each including the empty univs bracket
are objects. The Univs is an empty bracket but this is not equivalent to a value
of none. It has a value, just nothing within that value.
Univs = [ ], univs.append(techs)
This prints: [ [ 'MIT', "Cal Tech' ] ] The function defined in this code takes the variable of univs and prints its
current list and places the techs list within its own list.
Method is a word for a function with a different syntax. (This will be
discussed further in future lessons)
Objects, Methods, Flatten
Univs = Techs + Ivys
The plus sign turns two separate lists into just one list. Python
printed the following in response to the above input:
[ ' MIT', 'Cal Tech', 'Harvard', 'Yale', 'Brown', ] The two lists are combined to return one list of five strings(or values as
defined previously within list command)
Follows is a most appropriate function considering a real world problem with
our current list:
This simply states to remove Harvard from the list of Ivy's.
L = [ '1', 'MIT', 3.3, [ 'a' ] ]
returned these results:
[ '1', 'MIT', 3.2999999999999….', [ 'a' ] ]
L.remove ( 'MIT' ) (removes MIT_
L [ 0 ] Returns the first value just like strings.
L [ -1 ] Returns the last element(value) of the list, also like strings.
The above is my personal notes in regards to this class to help me in the