diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..b5f456cad 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,10 @@ # bounce.py # # Exercise 1.5 +height = 100 # meters +reboundRate = 0.6 +nBounces = 10 + +for iB in range(nBounces): + height = height*reboundRate + print(round(height, 4)) \ No newline at end of file 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/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 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)