diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..0210a6063 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,9 @@ # bounce.py # # Exercise 1.5 +height = 100 +coeff = 3.0/5 + +for i in range(10): + height = height * coeff + print(round(height,4)) \ No newline at end of file diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..1a859bdce 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 + +extra_payment_start_month = 12*5 +extra_payment_end_month = extra_payment_start_month + 4*12 +extra_payment = 1000 + +i = 1 +extra=0 +while principal > 0: + if i >= extra_payment_start_month and i <= extra_payment_end_month: + extra = extra_payment + if ((principal * (1+rate/12)) > (payment + extra)): + principal = principal * (1+rate/12) - (payment + extra) + total_paid = total_paid + payment + extra + else: + total_paid = total_paid + (principal * (1+rate/12)) + principal = 0 + extra = 0 + print (i, total_paid, principal) + i = i+1 +print('Total paid', total_paid, "months", i-1) \ No newline at end of file diff --git a/Work/sears.py b/Work/sears.py new file mode 100644 index 000000000..8add59254 --- /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) \ No newline at end of file