From b5ca3c218806432c9922370445166a9fdf5772c4 Mon Sep 17 00:00:00 2001 From: Rifat Majumder Date: Sat, 20 Jun 2020 23:52:07 +1000 Subject: [PATCH 1/3] Add Exercise 1.5 solution --- Work/bounce.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 7c4505a028f9fe26c3b0fd61372f228036f51def Mon Sep 17 00:00:00 2001 From: Rifat Majumder Date: Sat, 20 Jun 2020 23:54:26 +1000 Subject: [PATCH 2/3] Add Exercise 1.6 solution --- Work/sears.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Work/sears.py 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) From 3afb69e669bb546be67427655fd3b3c1b2b7a2be Mon Sep 17 00:00:00 2001 From: Rifat Majumder Date: Sun, 21 Jun 2020 12:13:33 +1000 Subject: [PATCH 3/3] Add Exercise 1.8 solution --- Work/mortgage.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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)