The following is part of a on-going collection of Jupyter notebooks. The goal being to have a library of notebooks as an introduction to Mathematics and technology. These were all created by Gavin Waters. If you use these notebooks, be nice and throw up a credit somewhere on your page.

if-then statement

This one the most common conditional statements in all of programing, it simply sets up a boolean test and then if it passes does something. The structure in python is very easy.

if boolean-test :

do this stuff
more stuff
even more stuff
last bit of stuff

after the stuff is done the program continues

You can also attach an else condition to the if statement.

There is also elif conditions that can placed in sequence, first the if then the next elif condition etc etc until some boolean condition becomes true then it exits the statement.

for loops

Neat little things used for repedative tasks. You should have a parameter that you are moving through a list that is set up.

Like the if statement in that you have the for then a boolean with " : "

while loops

Similar to the for loop.

Notice that the full while statement is carried out and then the while conditional is checked.

The while condition is create for letting the computer do the work for you.

Consider the following example, $f(x)=x^2+6x-16=(x+8)(x-2)$. We know there is some roots somewhere between -20 and 20. Lets see if there is an integer root.

Another thing it can do is allow you to manually input information

Lets assume that $f(x)=42x^2-17x-15$. Can we set up a script to guess where there root is?