Here's what running my homework programs looks like. For each, I start by running it on something simple where I know what the answer should be, to test what it's doing. In some cases debugging print statements should be used to watch it work, and then commented out for the final version. - Jim ===== chap 2, exercise 1 =============================== thirty-two:Desktop$ python chap2ex1.py -- chap2ex1.py ------------------------------------ This is a program to convert Celsius to Fahrenheit. So there. (Are we having fun yet?) --------------------------------------------------- What is the Celsius temperature? 20 The temperature is 68.0 degrees Fahrenheit. ===== chap 2, exercise 7 =============================== thirty-two:Desktop$ python chap2ex7.py --- chap2ex7.py : compound interest What is the annual percent interest rate? (i.e. 3.0) 3.0 How many periods are there per year? (i.e. 12) 12 What is the initial principal? (i.e. 100.00) 100.00 principal = 100.25 after 1 months principal = 100.500625 after 2 months principal = 100.751876562 after 3 months principal = 101.003756254 after 4 months principal = 101.256265645 after 5 months principal = 101.509406309 after 6 months principal = 101.763179824 after 7 months principal = 102.017587774 after 8 months principal = 102.272631743 after 9 months principal = 102.528313323 after 10 months principal = 102.784634106 after 11 months principal = 103.041595691 after 12 months principal = 103.299199681 after 13 months principal = 103.55744768 after 14 months principal = 103.816341299 after 15 months principal = 104.075882152 after 16 months principal = 104.336071858 after 17 months principal = 104.596912037 after 18 months principal = 104.858404317 after 19 months principal = 105.120550328 after 20 months principal = 105.383351704 after 21 months principal = 105.646810083 after 22 months principal = 105.910927108 after 23 months principal = 106.175704426 after 24 months principal = 106.441143687 after 25 months principal = 106.707246546 after 26 months principal = 106.974014663 after 27 months principal = 107.2414497 after 28 months principal = 107.509553324 after 29 months principal = 107.778327207 after 30 months principal = 108.047773025 after 31 months principal = 108.317892458 after 32 months principal = 108.588687189 after 33 months principal = 108.860158907 after 34 months principal = 109.132309304 after 35 months principal = 109.405140077 after 36 months principal = 109.678652927 after 37 months principal = 109.95284956 after 38 months principal = 110.227731684 after 39 months principal = 110.503301013 after 40 months principal = 110.779559265 after 41 months principal = 111.056508164 after 42 months principal = 111.334149434 after 43 months principal = 111.612484808 after 44 months principal = 111.89151602 after 45 months principal = 112.17124481 after 46 months principal = 112.451672922 after 47 months principal = 112.732802104 after 48 months principal = 113.014634109 after 49 months principal = 113.297170695 after 50 months principal = 113.580413621 after 51 months principal = 113.864364655 after 52 months principal = 114.149025567 after 53 months principal = 114.434398131 after 54 months principal = 114.720484126 after 55 months principal = 115.007285337 after 56 months principal = 115.29480355 after 57 months principal = 115.583040559 after 58 months principal = 115.87199816 after 59 months principal = 116.161678156 after 60 months principal = 116.452082351 after 61 months principal = 116.743212557 after 62 months principal = 117.035070588 after 63 months principal = 117.327658265 after 64 months principal = 117.62097741 after 65 months principal = 117.915029854 after 66 months principal = 118.209817428 after 67 months principal = 118.505341972 after 68 months principal = 118.801605327 after 69 months principal = 119.09860934 after 70 months principal = 119.396355864 after 71 months principal = 119.694846753 after 72 months principal = 119.99408387 after 73 months principal = 120.29406908 after 74 months principal = 120.594804253 after 75 months principal = 120.896291263 after 76 months principal = 121.198531991 after 77 months principal = 121.501528321 after 78 months principal = 121.805282142 after 79 months principal = 122.109795347 after 80 months principal = 122.415069836 after 81 months principal = 122.72110751 after 82 months principal = 123.027910279 after 83 months principal = 123.335480055 after 84 months principal = 123.643818755 after 85 months principal = 123.952928302 after 86 months principal = 124.262810623 after 87 months principal = 124.573467649 after 88 months principal = 124.884901318 after 89 months principal = 125.197113572 after 90 months principal = 125.510106356 after 91 months principal = 125.823881621 after 92 months principal = 126.138441326 after 93 months principal = 126.453787429 after 94 months principal = 126.769921897 after 95 months principal = 127.086846702 after 96 months principal = 127.404563819 after 97 months principal = 127.723075228 after 98 months principal = 128.042382917 after 99 months principal = 128.362488874 after 100 months principal = 128.683395096 after 101 months principal = 129.005103584 after 102 months principal = 129.327616343 after 103 months principal = 129.650935384 after 104 months principal = 129.975062722 after 105 months principal = 130.300000379 after 106 months principal = 130.62575038 after 107 months principal = 130.952314756 after 108 months principal = 131.279695543 after 109 months principal = 131.607894781 after 110 months principal = 131.936914518 after 111 months principal = 132.266756805 after 112 months principal = 132.597423697 after 113 months principal = 132.928917256 after 114 months principal = 133.261239549 after 115 months principal = 133.594392648 after 116 months principal = 133.92837863 after 117 months principal = 134.263199576 after 118 months principal = 134.598857575 after 119 months principal = 134.935354719 after 120 months Done. After 10 years, the principal is 134.935354719 ===== chap 2, exercise 10 =============================== thirty-two:Desktop$ python chap2ex10.py -- chap2ex10.py -- Convert mm/month to miles/hour. (Wikipedia says hair growth is ~ 125mm/month.) What is the speed in mm/month? (i.e. 125) 125 In miles/hour that is 1.063286215e-07 ===== chap 3, exercise 12 =============================== Sum of cubes of 1 ... n thirty-two:Desktop$ python chap3ex12.py -- chap3ex12.py -- Find the sum of the cubes of the first n integers. What is n? 1 The sum of 1**3 + ... + 1 **3 is 1 thirty-two:Desktop$ python chap3ex12.py -- chap3ex12.py -- Find the sum of the cubes of the first n integers. What is n? 2 The sum of 1**3 + ... + 2 **3 is 9 thirty-two:Desktop$ python chap3ex12.py -- chap3ex12.py -- Find the sum of the cubes of the first n integers. What is n? 10 The sum of 1**3 + ... + 10 **3 is 3025 ===== chap 3, exercise 14 =============================== -- chap3ex14.py -- Find the average of numbers entered by the user. How many numbers will be input? 3 number 1: 1 number 2: 1 number 3: 4 The average is 2.0 thirty-two:Desktop$ python chap3ex14.py -- chap3ex14.py -- Find the average of numbers entered by the user. How many numbers will be input? 8 number 1: 3 number 2: 2.5 number 3: 2 number 4: 2 number 5: 7 number 6: 8 number 7: 9 number 8: 12 The average is 5.6875 ===== chap 3, exercise 16 =============================== thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 0 F[ 0 ] = 0 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 1 F[ 1 ] = 1 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 2 F[ 2 ] = 1 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 3 F[ 3 ] = 2 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 4 F[ 4 ] = 3 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 7 F[ 7 ] = 13 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 10 F[ 10 ] = 55 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 100 F[ 100 ] = 354224848179261915075 thirty-two:Desktop$ python chap3ex16.py -- chap3ex16.py -- Find the n'th Fibonnaci number. What is n? 1000 F[ 1000 ] = 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875