From aeda1d907c127b799ee2d5dc2a8f366563c9e5c0 Mon Sep 17 00:00:00 2001 From: jiunsiew Date: Wed, 12 Jan 2022 17:40:25 +1100 Subject: [PATCH 1/4] Add files via upload intro scripts --- Work/hello.py | 6 ++++++ Work/sears.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Work/hello.py create mode 100644 Work/sears.py diff --git a/Work/hello.py b/Work/hello.py new file mode 100644 index 000000000..fd0370739 --- /dev/null +++ b/Work/hello.py @@ -0,0 +1,6 @@ +# hello.py +print('hello world') + +name = input('Enter your name: ') +print('Hello', name, end='') +print(', nice to meet you') \ No newline at end of file diff --git a/Work/sears.py b/Work/sears.py new file mode 100644 index 000000000..d59dc3b9a --- /dev/null +++ b/Work/sears.py @@ -0,0 +1,14 @@ +# sears.py +bill_thickness = 0.11/10/100 # 0.11 mm converted to meters +sears_height = 442 +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 bills:', num_bills) +print('Number of days:', day) +print('Final height: ', num_bills*bill_thickness) From f304fa9b694f33baf41c967f071e07396186f09d Mon Sep 17 00:00:00 2001 From: Jiun Siew Date: Thu, 13 Jan 2022 10:02:03 +1100 Subject: [PATCH 2/4] testing commit --- Work/bounce.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..a51c86cf3 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,4 @@ # bounce.py # # Exercise 1.5 +height = 100 # meters \ No newline at end of file From 7625b811c1015a2295982596c22269aefaaa6627 Mon Sep 17 00:00:00 2001 From: Jiun Siew Date: Thu, 13 Jan 2022 10:09:59 +1100 Subject: [PATCH 3/4] Update bounce.py Completing bounce.py exercise --- Work/bounce.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Work/bounce.py b/Work/bounce.py index a51c86cf3..639591a92 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,4 +1,10 @@ # bounce.py # # Exercise 1.5 -height = 100 # meters \ No newline at end of file +height = 100 # meters +reboundRate = 0.6 +nBounces = 10 + +for iB in range(nBounces): + height = height*reboundRate + print(height) From aad4bdc759e34fa82bb0b82a773476a25ee63f93 Mon Sep 17 00:00:00 2001 From: Jiun Siew Date: Thu, 13 Jan 2022 17:47:17 +1100 Subject: [PATCH 4/4] progressing more examples --- Work/bounce.py | 2 +- Work/mortgage.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Work/bounce.py b/Work/bounce.py index 639591a92..b5f456cad 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -7,4 +7,4 @@ for iB in range(nBounces): height = height*reboundRate - print(height) + print(round(height, 4)) \ No newline at end of file diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..3826d0f37 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,3 +1,26 @@ # mortgage.py # # Exercise 1.7 +principal = 500000.0 +rate = 0.05 +payment = 2684.11 +total_paid = 0.0 + +extraPaymentStartMonth = 61 +extraPaymentEndMonth = 108 +extraPayment = 1000 + +iMonth = 1 +while principal > 0: + + if iMonth >= extraPaymentStartMonth and iMonth < extraPaymentEndMonth: + tmpExtraPayment = extraPayment + else: + tmpExtraPayment = 0 + principal = principal * (1+rate/12) - (payment + tmpExtraPayment) + total_paid = total_paid + payment + tmpExtraPayment + print(iMonth, total_paid, principal) + iMonth = iMonth + 1 + +print('Total paid:', total_paid) +print('Number of Months:', iMonth-1) \ No newline at end of file