diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..3a5e99afa 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,11 @@ # bounce.py # # Exercise 1.5 + +height = 100 # Meters +bounce_count = 1 + +while bounce_count <= 10: + height *= 0.6 + print(bounce_count, round(height, 4)) + bounce_count += 1 diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..34f7c4c17 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,3 +1,25 @@ # mortgage.py # # Exercise 1.7 + +principal = 500000.0 +rate = 0.05 +payment = 2684.11 +extra_payment = 1000.0 +total_paid = 0.0 +month = 0 + +while principal > 0: + month = month + 1 + + if month <= 12: + principal = principal * (1+rate/12) - (payment + extra_payment) + total_paid = total_paid + payment + extra_payment + else: + principal = principal * (1+rate/12) - payment + total_paid = total_paid + payment + + + +print('Total paid', round(total_paid, 1)) +print('Months required', month) diff --git a/Work/sears.py b/Work/sears.py new file mode 100644 index 000000000..df968fff7 --- /dev/null +++ b/Work/sears.py @@ -0,0 +1,15 @@ +# sears.py + +bill_thickness = 0.11 * 0.001 # Meters (0.11 mm) +sears_height = 442 # Height (meters) +num_bills = 1 +day = 1 + +while num_bills * bill_thickness < sears_height: + print(day, num_bills, num_bills * bill_thickness) + day = day + 1 + num_bills = num_bills * 2 + +print('Number of days', day) +print('Number of bills', num_bills) +print('Final height', num_bills * bill_thickness)