Class 11 – Friday, February 26

Odds, ends, and beginnings

Lest we go forward — We cannot come back again — But beware of baths


Look both ways


Agenda


Downloads

 

 

 


To do list


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!



Program slice_of_pie.py

Enter favorite pie: anchovies and garlic

Enter two indices: 3 15

s: anchovies and garlic

i: 3

j: 15

s[ i ]: h

s[ j ]: a

s[ i : j ]: hovies and g

s[ i : ]: hovies and garlic

s[ : j ]: anchovies and g

s[ : ]: anchovies and garlic

Enter favorite pie: strawberry rhubarb

Enter two indices: 12 14

s: strawberry rhubarb

i: 12

j: 14

s[ i ]: h

s[ j ]: b

s[ i : j ]: hu

s[ i : ]: hubarb

s[ : j ]: strawberry rhu

s[ : ]: strawberry rhubarb



Chrestomathics — program secret_decoder.py

'abcdefghijklmnopqrstuvwxyz-'

and the indices are

[ 4, 8, 26, 4, 8, 26, 14 ]

'ei-ei-o'

Because s[ 4 ] equals 'e';   s[ 8 ] equals 'i';   s[ 14 ]; equals 'o';   and s[ 26 ] equals '-'.

Enter code phrase: computer

Code phrase: computer

Enter indices: 3 6 5

Indices: [3, 6, 5]

Hidden message: pet


Enter code phrase: gosh look what the cat is up to now

Code phrasee: gosh look what the cat is up to now

Enter indices: 24 5 17 17 27 23 32 0

Indices: [24, 5, 17, 17, 27, 23, 32, 0]

Hidden message: sleeping


Enter code phrase: ‐abcdefghijklmnopqrstuvwxyz‐

Code phrase: ‐abcdefghijklmnopqrstuvwxyz-

Enter indices: 12 15 22 5 27 9 19 0 1 12 12 27 14 5 5 4

Indices: [12, 15, 22, 5, 27, 9, 19, 0, 1, 12, 12, 27, 14, 5, 5, 4]

Hidden message: love‐is‐all‐need



Program thats_printastic.py

Wa-Hoo-Wa

Rah-Rah-Rah

Wa-Hoo-Wa!Rah-Rah-Rah

Wa-Hoo-Wa! Rah-Rah-Rah

t-a-t-t-a-r-r-a-t-t-a-t-

s a i p p u a k i v i k a u p p i a s

saippuakivikauppias



Program c_looper.py

row : 0 1 2 ... n-1

Enter number of columns: 5

row : 0 1 2 3 4


Enter number of columns: 12

row : 0 1 2 3 4 5 6 7 8 9 10 11



Program dataset_intro.py

table: [['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'], ['J', 'K', 'L', 'M']]

the table has 4 rows

row ['A', 'B', 'C'] has 3 columns

row ['D', 'E', 'F'] has 3 columns

row ['G', 'H', 'I'] has 3 columns

row ['J', 'K', 'L', 'M'] has 4 columns

row 0 : ['A', 'B', 'C']

row 1 : ['D', 'E', 'F']

row 2 : ['G', 'H', 'I']

row 3 : ['J', 'K', 'L', 'M']

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.