Class 07 – Monday, February 15

Make Bill Murray proud

Take another step — Chrestomathics awaits you — Feel the momentum

Camouflage not needed — Do not hide what makes you, you — You are welcomed here


Look both ways


Important survey


What I want to accomplish today


I should not show this complimenter.py interaction, but I am going to do it anyway

How old are you? 24

If aliens descended from space, they would classify you as 19



Agenda


Downloads


To do list


Program temperature.py

f = 9/5 * c + 32

Enter Celsius temperature: 24

24 C = 75.2 F

24 C = 75 F

Enter Celsius temperature: 8

8 C = 46.4 F

8 C = 46 F



Program break_the_bank.py

ugly output

Number of quarters, dimes, nickels, and pennies: 27 14 28 18

Coinage

    27 quarters

    14 dimes

    28 nickels

    18 pennies

are worth 9.73 dollars

Number of quarters, dimes, nickels, and pennies: 1 2 3 4

Coinage

    1 quarters

    2 dimes

    3 nickels

    4 pennies

are worth 0.64 dollars



Program indexing.py

Program output

### [] is the string index operator

s: sequoia

  0123456

n = len( s ): 7

s[ 0 ]: s

s[ 4 ]: o

s[ n-1 ]: a



Program lickety_strip_and_split.py

q: ' There is a door open to walk through '

### mis-attempted stripping

q.strip()

q: ' There is a door open to walk through '

### stripping

s = q.strip()

q: ' There is a door open to walk through '

s: 'There is a door open to walk through'

### splitting

f: 'bananas $0.69'

c: 'SEAS CS 1112'

fruit, price = f.split()

bananas costs $0.69 per pound

school, subject, number = c.split()

School: SEAS subject: CS number: 1112

### list making

list1 = f.split()

list2 = c.split()

list1: ['bananas', '$0.69']

list2: ['SEAS', 'CS', '1112']



Program love_is_all_you_need.py

Enter number of lines to be printed: 5

Love is all you need

Love is all you need

Love is all you need

Love is all you need

Love is all you need

Enter number of lines to be printed: 1

Love is all you need

Enter number of lines to be printed: 0



Program thats_amore.py

Enter text: love amore salanghae

love

amore

salangha

Enter text: upendo grá cinta Ai

upendo

grá

cinta

Ai




bill murray



 


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