From 77de228cc049f8d8ad59e11fe5154fa497ebc643 Mon Sep 17 00:00:00 2001 From: Wilson Usman Date: Sun, 31 May 2020 11:10:28 -0400 Subject: [PATCH 1/2] Completed search exercise --- Solutions/1_10/mortgage.py | 12 +++++++----- Solutions/1_5/bounce.py | 4 ++-- Work/mortgage.py | 11 +++++++++++ Work/sears.py | 13 +++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 Work/sears.py diff --git a/Solutions/1_10/mortgage.py b/Solutions/1_10/mortgage.py index 23ecacaf6..9699b69b8 100644 --- a/Solutions/1_10/mortgage.py +++ b/Solutions/1_10/mortgage.py @@ -1,14 +1,16 @@ # mortgage.py -principal = 500000.0 -rate = 0.05 -payment = 2684.11 +principal = int(200000.0) +rate = float(0.05) +payment = int(1633.11) total_paid = 0.0 month = 0 +start_extra_payment_on_year = 5 +extra_years = 4 extra_payment = 1000.0 -extra_payment_start_month = 60 -extra_payment_end_month = 108 +extra_payment_start_month = start_extra_payment_on_year * 12 +extra_payment_end_month = extra_payment_start_month + (extra_years * 12) while principal > 0: month = month + 1 diff --git a/Solutions/1_5/bounce.py b/Solutions/1_5/bounce.py index 1f3fa5317..aed6303f1 100644 --- a/Solutions/1_5/bounce.py +++ b/Solutions/1_5/bounce.py @@ -2,7 +2,7 @@ height = 100 bounce = 1 -while bounce <= 10: +while bounce <= 20: height = height * (3/5) - print(bounce, round(height, 4)) + print(bounce, round(height, 2)) bounce += 1 diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..3c81861b2 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,3 +1,14 @@ # mortgage.py # # Exercise 1.7 +principal = 500000.0 +rate = 0.05 +payment = 2684.11 +total_paid = 0.0 + + +while principal > 0: + principal = principal * (1+rate/12) - payment + total_paid = total_paid + payment + +print('Total paid', total_paid) \ No newline at end of file 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 From 14af1efdb1ff51d38b0c40df6d6212398e6d5a23 Mon Sep 17 00:00:00 2001 From: Wilson Usman Date: Sun, 31 May 2020 11:12:58 -0400 Subject: [PATCH 2/2] Revert "Completed search exercise" This reverts commit 77de228cc049f8d8ad59e11fe5154fa497ebc643. --- Solutions/1_10/mortgage.py | 12 +++++------- Solutions/1_5/bounce.py | 4 ++-- Work/mortgage.py | 11 ----------- Work/sears.py | 13 ------------- 4 files changed, 7 insertions(+), 33 deletions(-) delete mode 100644 Work/sears.py diff --git a/Solutions/1_10/mortgage.py b/Solutions/1_10/mortgage.py index 9699b69b8..23ecacaf6 100644 --- a/Solutions/1_10/mortgage.py +++ b/Solutions/1_10/mortgage.py @@ -1,16 +1,14 @@ # mortgage.py -principal = int(200000.0) -rate = float(0.05) -payment = int(1633.11) +principal = 500000.0 +rate = 0.05 +payment = 2684.11 total_paid = 0.0 month = 0 -start_extra_payment_on_year = 5 -extra_years = 4 extra_payment = 1000.0 -extra_payment_start_month = start_extra_payment_on_year * 12 -extra_payment_end_month = extra_payment_start_month + (extra_years * 12) +extra_payment_start_month = 60 +extra_payment_end_month = 108 while principal > 0: month = month + 1 diff --git a/Solutions/1_5/bounce.py b/Solutions/1_5/bounce.py index aed6303f1..1f3fa5317 100644 --- a/Solutions/1_5/bounce.py +++ b/Solutions/1_5/bounce.py @@ -2,7 +2,7 @@ height = 100 bounce = 1 -while bounce <= 20: +while bounce <= 10: height = height * (3/5) - print(bounce, round(height, 2)) + print(bounce, round(height, 4)) bounce += 1 diff --git a/Work/mortgage.py b/Work/mortgage.py index 3c81861b2..d527314e3 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,14 +1,3 @@ # mortgage.py # # Exercise 1.7 -principal = 500000.0 -rate = 0.05 -payment = 2684.11 -total_paid = 0.0 - - -while principal > 0: - principal = principal * (1+rate/12) - payment - total_paid = total_paid + payment - -print('Total paid', total_paid) \ No newline at end of file diff --git a/Work/sears.py b/Work/sears.py deleted file mode 100644 index f5778dd21..000000000 --- a/Work/sears.py +++ /dev/null @@ -1,13 +0,0 @@ -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