Class 4 – Wednesday, August 31

Variation on a theme

A variable — Is like a box or a name — We must all know this

The #metoo movement — Calls out to everyone — Female Lives Matter


Look both ways


Aside


What is happening today


Current and future examples (download them all, some have been updated)


A code walk through — getting a mental model of variables and assignment


Agenda


Important questions that I hoped were answered last time


Whoops

Purpose: correct errant code

Author: Jim Cohoon

Id: jpc

  print( We learn best, when we must invent. -- Jean Piaget

We learn best, when we must invent. -- Jean Piaget


Program intsy_bitsy.py

Values of interest

a: 20

b: 3

Results

a + b: 23

a - b: 17

a * b: 60

a / b: 6.666666666666667

a // b: 6

a ** b: 8000

a % b: 2



Program floatilla.py

Values of interest

x: 2.71

y: 3.14

Results

x + y: 5.85

x - y: -0.43000000000000016

x * y: 8.5094

x / y: 0.8630573248407643

x // y: 0.0

x ** y: 22.883559193263366

x % y: 2.71



Program variety.py


Program hip_hopping.py

Generation: 1

Rabbits: 2

Generation: 2

Rabbits: 4

Generation: 3

Rabbits: 8

Generation: 4

Rabbits: 16


Program psychoanalyst.py

Tell me what is on your mind: Worrying about the future

 

That tells me a lot about you.

 

I wish we had more time to chat. So long.

Tell me what is on your mind: Fluttering butterfly

 

That tells me a lot about you.

 

I wish we had more time to chat. So long.

Tell me what is on your mind: Is Superman colorblind

 

That tells me a lot about you.

 

I wish we had more time to chat. So long.



Program favorite_word.py

Another use of the built-in function input().

Introduces the built-in function len().

Tell me a favorite word: crwth

 

Did you know that crwth has length 5

Tell me a favorite word: strengths

 

Did you know that strengths has length 9

Tell me a favorite word: squirreled

 

Did you know that squirreled has length 10



Program combine_replicate.py

### operator + performs concatenation

a = fire

b = fighter

a + b = firefighter

### * operator produces repeated concatenation

m = Wahoo-Wah!

n = 3

m * n = Wahoo-Wah!Wahoo-Wah!Wahoo-Wah!

n * m = Wahoo-Wah!Wahoo-Wah!Wahoo-Wah!



To do list




wikimedia creative commons license rabbits galore


open clipart derived crwth