Tuples

x = (1,4,"a",3)
print(x[1])   ## indexing
## 4
print(x[2:])  ## slicing
## ('a', 3)
print(x+(3,)) ## appending
## (1, 4, 'a', 3, 3)
print(x[:2] + (3,) + x[2:]) ## insertion in the middle
## (1, 4, 3, 'a', 3)
x.index(4)    ## indexing
## 1
"z" in x      ## looking for stuff
## False
x.count(4)    ## count
## 1
x = (1,2,3)
def modify(x):
    y = list(x)
    y[0] = "a"
    return(tuple(y))

print(modify(x))
## ('a', 2, 3)
print(x)
## (1, 2, 3)

reminders/clarifications

" actually (mostly) optional*: see here

Root-finding methods

We will use three methods (Grid, Bisection, and Newton’s method) to approximate such a number \(c\). (There may be more than one root of \(f\) in the interval between \(a\) and \(b\).)

Example

Grid Method

Bisection Method

Newton’s Method