From c8af82ade3265b9233314ec4524971ec7eee919a Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov <50961907+Lipofrenik@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:50:06 +0000 Subject: [PATCH 1/8] Create hello.py --- Work/hello.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 Work/hello.py diff --git a/Work/hello.py b/Work/hello.py new file mode 100644 index 000000000..ad35e5ae3 --- /dev/null +++ b/Work/hello.py @@ -0,0 +1 @@ +print("Hello World") From 123ed2d0fab5f3e8014130435a33b7c6de41c495 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Thu, 14 Nov 2024 17:12:35 +0000 Subject: [PATCH 2/8] Add sears.py to Work directory --- Work/sears.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Work/sears.py diff --git a/Work/sears.py b/Work/sears.py new file mode 100644 index 000000000..e69de29bb From 4747b5248ac7aaa44ea38e01a7a23a8ff509a411 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Thu, 14 Nov 2024 18:15:04 +0000 Subject: [PATCH 3/8] Added code to sears.py --- Work/sears.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Work/sears.py b/Work/sears.py index e69de29bb..681239f2b 100644 --- a/Work/sears.py +++ b/Work/sears.py @@ -0,0 +1,15 @@ + +bill_thickness = 0.11 * 0.001 # Meters +sears_height = 442 # height meters +day = 1 +num_bills = 1 + +while bill_thickness * num_bills < 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 c253af7d6088f2fe4fda7f85f6b599ff5d39e007 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Thu, 14 Nov 2024 18:43:39 +0000 Subject: [PATCH 4/8] Completed exercise and saved it to bounce.py --- Work/bounce.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Work/bounce.py b/Work/bounce.py index 3660ddd82..429a9ae4d 100644 --- a/Work/bounce.py +++ b/Work/bounce.py @@ -1,3 +1,10 @@ # bounce.py # # Exercise 1.5 +height = 100 +i=1 +while i < 10: + height = height * 0.6 + i = i+1 + print(i, height) + From 731386754213cca43d6a70dcdff7713f96344db4 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Sat, 16 Nov 2024 21:54:00 +0000 Subject: [PATCH 5/8] Completed exercise 1.8 and saved it to mortgage.py --- Work/mortgage.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Work/mortgage.py b/Work/mortgage.py index d527314e3..a5189c924 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -1,3 +1,27 @@ # mortgage.py # # Exercise 1.7 + + +principal = 500000.0 +rate = 0.05 +payment = 2684.11 +total_paid = 0.0 +month=0 +new_payment = 3684.11 +while principal > 0: + if month < 12: # First 12 months with extra payment + principal = principal * (1+rate/12) - new_payment + total_paid = total_paid + new_payment + else: # Regular payment after 12 months + principal = principal * (1+rate/12) - payment + total_paid = total_paid + payment + month = month + 1 + + # Final Adjustment if the principal goes negative + if principal < 0: + total_paid = total_paid + principal # Adjust the last payment + principal = 0 # Set principal to 0 to exit the loop +print("Total Paid: ", round(total_paid, 2)) +print("Months spent:", month) + From 3e14af1710e7d9f494a17c81ef2257801a7fb11a Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Mon, 18 Nov 2024 19:30:38 +0000 Subject: [PATCH 6/8] Completed exercise 1.10 and saved it to mortgage.py --- Work/mortgage.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Work/mortgage.py b/Work/mortgage.py index a5189c924..3d18e3bfb 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -7,21 +7,26 @@ rate = 0.05 payment = 2684.11 total_paid = 0.0 -month=0 -new_payment = 3684.11 +month = 0.0 + +#User-defined extra payment variables +extra_payment_start_month=61 # Extra payments start after 5 years (month 61) +extra_payment_end_month = 108 # Extra payments end after 4 years (month 108) +extra_payment = 1000 # Extra payment amount while principal > 0: - if month < 12: # First 12 months with extra payment - principal = principal * (1+rate/12) - new_payment - total_paid = total_paid + new_payment - else: # Regular payment after 12 months - principal = principal * (1+rate/12) - payment - total_paid = total_paid + payment - month = month + 1 - - # Final Adjustment if the principal goes negative + # Chack if the current month is within the extra payment period + if extra_payment_start_month <= month < extra_payment_end_month: + monthly_payment = extra_payment + payment + else: + monthly_payment = payment + # Apply monthly interest and substract the payment + principal = principal * (1+rate/12) - payment + total_paid += monthly_payment + month +=1 + # Final adjustment if the principal goes negative if principal < 0: total_paid = total_paid + principal # Adjust the last payment principal = 0 # Set principal to 0 to exit the loop -print("Total Paid: ", round(total_paid, 2)) -print("Months spent:", month) + print(month, " ", total_paid) + From 2a7d1a74537980ecc87b99ae4b6e7aa497dbe451 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Tue, 26 Nov 2024 19:43:08 +0000 Subject: [PATCH 7/8] A little modification with the strings in mortgage.py --- Work/mortgage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Work/mortgage.py b/Work/mortgage.py index 3d18e3bfb..e9d07e237 100644 --- a/Work/mortgage.py +++ b/Work/mortgage.py @@ -27,6 +27,6 @@ if principal < 0: total_paid = total_paid + principal # Adjust the last payment principal = 0 # Set principal to 0 to exit the loop - print(month, " ", total_paid) + print(f'Month: {month} vs {total_paid}') From 0ef34098e18bb4be9b08c47ad0f537a4ca80b303 Mon Sep 17 00:00:00 2001 From: Dostonbek Rustamov Date: Thu, 28 Nov 2024 23:13:37 +0000 Subject: [PATCH 8/8] Completed exercise 1.27: Reading a data file and saved it to pcost.py --- Work/pcost.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Work/pcost.py b/Work/pcost.py index e68aa20b4..f0821097d 100644 --- a/Work/pcost.py +++ b/Work/pcost.py @@ -1,3 +1,21 @@ # pcost.py # # Exercise 1.27 +import csv +each_share = 0.0 +shares = 0.0 +prices = 0.0 +total_cost = 0 +with open('/Users/doston_ra/practical-python/Work/Data/portfolio.csv', 'rt') as file: + reader = csv.reader(file) + next(reader) + for line in reader: + + shares= float(line[1]) + prices = float(line[2]) + each_share = shares * prices + total_cost += each_share + +print('Total cost is ', total_cost) + +