File tree Expand file tree Collapse file tree 5 files changed +47
-0
lines changed
Expand file tree Collapse file tree 5 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 11# bounce.py
22#
33# Exercise 1.5
4+ startHeight = 60.0
5+ bounceCount = 1
6+ print (startHeight )
7+
8+ while bounceCount < 10 :
9+ startHeight = startHeight * .6
10+ print (round (startHeight ))
11+ bounceCount = bounceCount + 1
Original file line number Diff line number Diff line change 11# mortgage.py
22#
33# Exercise 1.7
4+ principal = 500000.0
5+ rate = 0.05
6+ payment = 2684.11
7+ total_paid = 0.0
8+ month = 1
9+
10+ while principal > 0 :
11+ principal = principal * (1 + rate / 12 ) - payment
12+ total_paid = total_paid + payment
13+
14+ if month <= 12 :
15+ principal = principal - 1000
16+
17+ month = month + 1
18+
19+ print ('Total paid' , total_paid )
20+ print ('Total time' , month )
Original file line number Diff line number Diff line change 11# pcost.py
22#
33# Exercise 1.27
4+ totalCost = 0
5+ f = open ('Data/portfolio.csv' , 'rt' )
6+ headers = next (f )
7+ for line in f :
8+ row = line .split (',' )
9+ totalCost = totalCost + int (row [1 ])* float (row [2 ])
10+
11+ f .close ()
12+ print ('Total Cost ' + str (totalCost ))
Original file line number Diff line number Diff line change 1+ bill_thickness = 0.11 * 0.001 # Meters (0.11 mm)
2+ sears_height = 442 # Height (meters)
3+ num_bills = 1
4+ day = 1
5+
6+ while num_bills * bill_thickness < sears_height :
7+ print (day , num_bills , num_bills * bill_thickness )
8+ day = day + 1
9+ num_bills = num_bills * 2
10+
11+ print ('Number of days' , day )
12+ print ('Number of bills' , num_bills )
13+ print ('Final height' , num_bills * bill_thickness )
You can’t perform that action at this time.
0 commit comments