From 60824e695405d2ed9e0c7bbb40a7c6fabef4259c Mon Sep 17 00:00:00 2001 From: HamzaIDM Date: Wed, 3 Dec 2025 12:10:41 +0100 Subject: [PATCH 1/3] First_Commit --- compound_interest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compound_interest.py b/compound_interest.py index 9673a7a0..8ba2505d 100644 --- a/compound_interest.py +++ b/compound_interest.py @@ -2,6 +2,7 @@ # Do not use this in production. Sample purpose only. # Author: Upkar Lidder (IBM) +# Updated by HamzaIDM # Input: # p, principal amount @@ -15,10 +16,13 @@ def compound_interest(p, t, r): return p * (pow((1 + r / 100), t)) - -if __name__ == "__main__": +def main(): p = float(input("Enter the principal amount: ")) t = float(input("Enter the time period: ")) r = float(input("Enter the rate of interest: ")) print("The compound interest is {:.2f}".format(compound_interest(p, t, r))) + + +if __name__ == "__main__": + main() \ No newline at end of file From 9b383a3477c666d83ef9a5146d5f2b5c777499b9 Mon Sep 17 00:00:00 2001 From: HamzaIDM Date: Wed, 3 Dec 2025 12:16:11 +0100 Subject: [PATCH 2/3] Second_Commit --- compound_interest.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/compound_interest.py b/compound_interest.py index 8ba2505d..e9eeece3 100644 --- a/compound_interest.py +++ b/compound_interest.py @@ -11,17 +11,25 @@ # Output: # compound interest = p * (1 + r/100)^t - +import sys def compound_interest(p, t, r): return p * (pow((1 + r / 100), t)) def main(): - p = float(input("Enter the principal amount: ")) - t = float(input("Enter the time period: ")) - r = float(input("Enter the rate of interest: ")) - print("The compound interest is {:.2f}".format(compound_interest(p, t, r))) + # for speed + read = sys.stdin.readline + write = sys.stdout.write + + write("Enter the principal amount: ") + p = float(read()) + write("Enter the time period: ") + t = float(read()) + write("Enter the interest rate: ") + r = float(read()) + + print(f"The compound interest is {compound_interest(p, t, r):.2f}") if __name__ == "__main__": From d59b35c636de04814f1e1ebc401fe134772a8924 Mon Sep 17 00:00:00 2001 From: HamzaIDM Date: Wed, 3 Dec 2025 12:36:56 +0100 Subject: [PATCH 3/3] SecondCommit --- compound_interest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compound_interest.py b/compound_interest.py index e9eeece3..06892c10 100644 --- a/compound_interest.py +++ b/compound_interest.py @@ -18,7 +18,7 @@ def compound_interest(p, t, r): def main(): - # for speed + # for speed read = sys.stdin.readline write = sys.stdout.write