Class 06 – Monday, September 6

Fearlessly we march on — variables and strings

A sign for knowing — what the future asks of us — demands we act now

I say love is love — For aren’t we all just people — Living as we are


Look both ways


Agenda


Examples


Inquiring minds want to know


Program being_powerful.py

  • Get inputs
  • Massage inputs into needed values
  • Compute result
  • Print result

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): 4

Enter exponent (decimal): 0.333

1.5866676863822857



Program trio.py

Enter three words: peace joy friends

Your words

peace

joy

friends

Enter three words: ready or not

Your words

ready

or

not



Program i_get_around.py

Enter number: 3.1415926

number: 3.1415926

round( number, 6 ): 3.141593

round( number, 5 ): 3.14159

round( number, 4 ): 3.1416

round( number, 3 ): 3.142

round( number, 2 ): 3.14

round( number, 1 ): 3.1

round( number, 0 ): 3.0

round( number ): 3

Enter number: 2.7182818

number: 2.7182818

round( number, 6 ): 2.718282

round( number, 5 ): 2.71828

round( number, 4 ): 2.7183

round( number, 3 ): 2.718

round( number, 2 ): 2.72

round( number, 1 ): 2.7

round( number, 0 ): 3.0

round( number ): 3



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 who_what_and_where.py

  • id( n ) identifies where in memory to find n
  • type( n ) supplies what type of value is n

Enter integer and decimal: 3 4.159

reply: 3 4.159 <class 'str'> 140400369925360

n: 3 <class 'int'> 9720640

x: 4.159 <class 'float'> 140400370194512

Enter integer and decimal: 8 8.88

reply: 8 8.88 <class 'str'> 139778356653296

n: 8 <class 'int'> 9720800

x: 8.88 <class 'float'> 139778356922448



Program the_old_switcheroo.py

reply = input( 'Enter two words: ' )

w1, w2 = reply.split()

print( )

print( 'w1 =', w1 )

print( 'w2 =', w2 )

print()

# swap the values of w1 and w2

w1 = w2

w2 = w1

# print results

print( 'After swapping' )

print()

print( 'w1 =', w1 )

print( 'w2 =', w2 )

Enter two words: wahoo wah

w1 = wahoo

w2 = wah

After swapping

w1 = wah

w2 = wah



Program all_consuming.py

What is something you consume daily? paper napkins

How much consumed on a typical weekday: 6

How much consumed on a typical weekend day: 0

You consume 1560 paper napkins per year.

What is something you consume daily? pretzels

How much consumed on a typical weekday: 0

How much consumed on a typical weekend day: 1

You consume 104 pretzels per year.

What is something you consume daily? jelly beans

How much consumed on a typical weekday: 4

How much consumed on a typical weekend day: 12

You consume 2288 jelly beans per year.



To do list


Homework 5 commentary

age1 = input( "Tell me your age:" )

age_orig = input( "You look awesome would you mind tell me how old you are?:" )

age = input("Hey there youngin'! How old are ya?")

print( " Really! You don't look a day over", Faux_age )

print("you dont look a day over",good_age)

print( "Your complimentary age is", complimentary_age )

print("You don't look a day over: ", jeff)

print( 'You do not look a day over', x - 5)

print( " Wow! I would've guessed ", n-5, " ! " )

print ("You do not even look " + str(age2))

print("You do not even look " + str(respond))

print( 'Whatttttt? You do not look a day over', ( str_age + '!' ) )

print( "I would never imagine you to be", str(age) + ", you look at most ", str(compliment_age) + "!" )

print("wow, you don't even look", total)

reply2 = print ( "If I hadn't asked, I would've thought you were ", computed_age )

print( "You don't even look", y )

reply2 = print( "Wow, you look beautiful enough to be", faux_age )

print( "Complimentary Age: ", complimentary_age )

print('Darling, your youth has been good to you. You do not look a day over', whatever_1,'! :)')

print ("Really?? That is quite the surprise you don't look a day over",new_age)

print ("You don't look a day over", n)

print("You don't look a day over", x)

print( "Woah, you look", x , "years young!" )

print ( 'wow you look like you are',Supposed_age,'not',reply1 )

print("You don't even look", b)

print ( "You Look Much younger, you look like you are:" , faux_age )




image from wikimedia.org, magical mystery tour album cover

All you need is love — All you need is love — All you need is love, love — Love is all you need.     The Beatles