From 13e7d4c35441dbe45afdedec9b8ff28b5bbd1b40 Mon Sep 17 00:00:00 2001 From: Jamie Faidley Date: Thu, 1 Oct 2020 17:49:11 -0500 Subject: [PATCH] * Done up until 1.5 on lists --- Work/bounce.py | 6 ++++++ Work/mortgage.py | 27 +++++++++++++++++++++++++++ Work/sears.py | 13 +++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 Work/sears.py diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..e16dd3ce3 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,9 @@ # bounce.py # # Exercise 1.5 + +height = 100 + +for i in range(10): + height = height * .6 + print(round(height,4)) \ No newline at end of file diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..33b1f789c 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,3 +1,30 @@ # mortgage.py # # Exercise 1.7 + +principal = 500000.0 +rate = 0.05 +payment = 2684.11 +total_paid = 0.0 + +extra_payment_start_month = 61 +extra_payment_end_month = 108 +extra_payment = 1000 + +month = 1 + +while principal > 0: + if extra_payment_start_month <= month <= extra_payment_end_month: + payment = payment + extra_payment + if principal <= payment: + payment = principal + principal = 0 + else: + principal = principal * (1+rate/12) - payment + + total_paid = total_paid + payment + payment = 2684.11 + month += 1 + print(f'After month {month} we have paid {total_paid} and have {principal} left!') + +print('Total paid', round(total_paid,2)) diff --git a/Work/sears.py b/Work/sears.py new file mode 100644 index 000000000..f5778dd21 --- /dev/null +++ b/Work/sears.py @@ -0,0 +1,13 @@ +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) \ No newline at end of file