Think Python C1

From XPUB & Lens-Based wiki
Revision as of 11:04, 15 October 2008 by Michael Murtaugh (talk | contribs) (→‎Exercise 1.4)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Chapter 1: The way of the program

Exercise 1.1

Good structure / bad tokens ->Ever3b0dy has w0n, and ell mast heve priz3s.

Bad structure / good tokens ->Everybody won has, must have prizes all and.

Exercise 1.4

a. Average time per mile

 43 min 30 secs = 43.5 minutes
 10km * 1 mile    =  10 / 1.61  =  6.21 miles
        ---- 
        1.61 km
 43.5 minutes  =  (43.5 / 6.21)
 ----
 6.21 miles

all together:

 >>> 43.5 / (10 / 1.61)
 7.0035000000000007
 answer: 7.00 minutes per mile

b. Average miles per hour

 6.21 miles    *  60 minutes 
 ----             ----
 43.5 minutes     1 hour
 >>> (6.21 / 43.5) * 60
 8.565517241379311
 answer: 8.57 miles / hour