CSE 801 – FS 2017

What happens when you solve programming problems?

rough plan, trial and error, lot’s of wrong, understand individual pieces, incremental steps, use the thing as it’s own model, virtual play and replay, goal oriented … beauty isn’t a concern, backwards planning – wishful thinking, it is a game, there is more than one solution

iPython notebook

%pylab inline … make this a habit!
be aware, the order of cell executions matters,

the procedure:

open conda environment
open jupyter (it is where it was started)
open a notebook
notebooks are active
notebooks need to be closed to be closed
jupyter needs to be closed to be not active anymore

errors

a new error is just a new error in a sequence of more errors … don’t be discouraged
seek to understand the error … the message is cryptic at best
read from the bottom!

variables

variables need to be defined … python has no clue about content or type beforehand
so far, we defined variables by assigning a value to them (= is an assign operation, not the mathematical “equal” expression)
Defining a string ‘,”,”’, str(somevariable)
Escape Character: \ the usefull ones are \n \t and \\
format is a useful command
Boolean is True or False

IF statements

AND OR conjugate statements -> order might not be clear: A AND B OR C means what? (A AND B) OR C or A AND (B OR C)?
NOT “nots” the truth
== this is a comparator operator, is the left side EQUAL to the right?
= is an assignment operator, let the left side be the right
other comparators:
== < > <= >= !=
else: expands the function of the “IF” statement, “ELSE” part becomes executed if the IF part isn’t True

Pretty little insight – life lesson – title in progress

Function before beauty – for now
The easier it is on your brain, the easier it is to implement for you, for now
There is always another way to do it, don’t judge appreciate 🙂
just starting sometimes helps

WHILE statements

Very much like an IF statement a WHILE statement evaluates a logic expression, but instead of running through the block conditioned on the logic expression, it keeps repeating the same block until the logic expression becomes False.

List

In order to initialize a list you write myList=list() or myList=[]. You can append elements, pop elements, insert elements, and remove elements.
The number in the [] is an index, so:
X[5] would refer to the 5th element in the list, observe that lists start counting from 0!

FOR loop

A FOR look iterates over all elements of a list and the running variable will become the values defined in the list one after the other.
for i in [3,4,7]:

would make i become 3, then 4, and then 7

In order to make things a bit more comfortable, there is the range() and the linspace() command that helps you generate lists on the fly with predefined values … (this is technically not correct, it creates an iterator or an array, but for now this is sufficient).

 

iPython Notebook intro – math, variables.ipynb

The weird dice problem to train while statements.ipynb

Conditional Statements (IF, WHILE).ipynb

Lists.ipynb

FOR loops.ipynb

BunnyFox.ipynb