Class 05 – Wednesday, February 10

It's all about you

Show understanding — Put it altogether now — Yes you all can do


Look both ways


Downloads


Agenda


All future homework requirements


To do list


Program casting.py

integer_string = '112358'

decimal_string = '93.86'

decimal_number = 9.04

integer_number = 1112

i1 = int( integer_string )

i2 = int( decimal_number )

f1 = float( integer_number )

f2 = float( decimal_string )

i1 + i2 = 112367

f1 + f2 = 1205.86

nbr1 = 14

nbr2 = 1.5

s1 = str( nbr1 )

s2 = str( nbr2 )

s1 + s2 = '141.5'



Program being_powerful.py

Enter base (integer): 2

Enter exponent (decimal): 0.5

 

1.4142135623730951

Enter base (integer): 11

Enter exponent (decimal): 3.14

 

1861.971509290233

Enter base (integer): 9

Enter exponent (decimal): 99.9

 

2.132201+95



Program trio.py

  • The final version of the program shows that every string has a member function for inspecting itself. The split() function hands back the list of words that make up the string.

What are your three favorite words: peace joy friends

 

peace

joy

friends

What are your three favorite words: you me us

 

you

me

us

What are your three favorite words: subcontinental nudiustertian uncopyrightable

 

subcontinental

nudiustertian

uncopyrightable



Program complimenter.py

  Enter your age: 19

  You don’t even look 14

  Enter your age: 111

  You don’t even look 106

  Enter your age: 20

  You don’t even look 15


Program tao.py

Enter rectangle width and height (integers): 5 6

 

30

Enter rectangle width and height (integers): 2 71

 

142

Enter rectangle width and height (integers): 3 14

 

42



variables as boxes

 


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