Skip to content

Commit f53f4ed

Browse files
committed
exercise complete
1 parent 9c3e2e3 commit f53f4ed

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

Work/PerformCalculation.py

Whitespace-only changes.

Work/bounce.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
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

Work/mortgage.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
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)

Work/pcost.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
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))

Work/sears.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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)

0 commit comments

Comments
 (0)