Class 09 – Monday, September 12

Do that again

Did you not expect – The repetition to come – Did you not expect

We are humankind — What a mantra that could be — I'm human and kind


Look both ways


Agenda


Word of the day


For the fun of it


Downloads


To do list


Program escaping.py

a: a b c d

b: "Air quotes" are annoying

c: Hello

 

Goodbye

 

len( a ): x

len( a ): 7

len( b ): 25



Program slice_of_pie.py

Enter favorite pie: chocolate

Enter two indices i and j: 3 8

s[ i : j ]: colat

s[ i : ]: colate

s[ : j ]: chocolat

s[ : ]: chocolate

Enter favorite pie: pizza

Enter two indices i and j: 2 3

s[ i : j ]: z

s[ i : ]: zza

s[ : j ]: piz

s[ : ]: pizza

Enter favorite pie: garlic tart

Enter two indices i and j: 1 8

s[ i : j ]: arlic t

s[ i : ]: arlic tart

s[ : j ]: garlic t

s[ : ]: garlic tart



Program kinda_stringy.py

Enter text: four score

f

o

u

r

s

c

o

r

e

Enter text: step by step, inch by inch, Niagara Falls

s

t

e

p

b

y

s

t

e

p

,

i

n

c

h

b

y

i

n

c

h

N

i

a

g

a

r

a

F

a

l

l

s



Program adage.py

range( a, b )

Produces the sequence of integers a, a + 1, ..., b - 1. Pay attention to this fact — the sequence ends before the value of the second argument.

Enter adage: We are humankind

Enter number of lines to be printed: 5

We are humankind

We are humankind

We are humankind

We are humankind

We are humankind

Enter adage: Love is all you need

Enter number of lines to be printed: 3

Love is all you need

Love is all you need

Love is all you need



Program in_support.py

s = "we are in it together"

values = [ ]

stuff = [ 'abc', 1112, 2.71, ]

digits = [ 3, 1, 4, 1, 5, 9, 2, 6 ]

words = s.split()

vlen = len( values )

slen = len( stuff )

dlen = len( digits )

wlen = len( words )

print( "size of", values, "=", vlen )

print( "size of", stuff, "=", slen )

print( "size of", digits, "=", dlen )

print( "size of", words, "=", wlen )

dmax = max( digits )

dmin = min( digits )

wmax = max( words )

wmin = min( words )

print( "max of", digits, "=", dmax )

print( "min of", digits, "=", dmin )

print( "max of", words, "=", wmax )

print( "min of", words, "=", wmin )

size of [] = 0

size of ['abc', 1112, 2.71] = 3

size of [3, 1, 4, 1, 5, 9, 2, 6] = 8

size of ['we', 'are', 'in', 'it', 'together'] = 5

max of [3, 1, 4, 1, 5, 9, 2, 6] = 9

min of [3, 1, 4, 1, 5, 9, 2, 6] = 1

max of ['we', 'are', 'in', 'it', 'together'] = we

min of ['we', 'are', 'in', 'it', 'together'] = are



Program building.py

values = [ ]

values.append( "u" )

values.append( "v" )

values.append( "a" )

values.append( "!" )

values.append( " " )

values.append( "u" )

values.append( "v" )

values.append( "a" )

values.append( "!" )

print( "values =", values )

ints = []

for i in range( 0, 10 ) :

  ints.append( i )

print( "ints =", ints

values = ['u', 'v', 'a', '!', ' ', 'u', 'v', 'a', '!']

ints = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]




Coney Island Cyclone roller coaster

Coney Island Cyclone


Schrödinger's cat

cat in a box