To make the code reusable and organized, you should put the part of the code that calculates the compound interest into a function. This would allow you to call that function with different rates and times for different conditions.
Here is an example of how you could write that function:
def calculate_compound_interest(principal, rate, time):
Amount = principal * (pow((1 + rate / 100), time))
return Amount + principal
# Now you can call the function for the first loan condition
principal = 10000
rate1 = 10.25
time1 = 5
total1 = calculate_compound_interest(principal, rate1, time1)
print("Compound interest is", total1)
# And for the second loan condition
rate2 = 5.25
time2 = 10
total2 = calculate_compound_interest(principal, rate2, time2)
print("Compound interest is", total2)
In this case, the code that should be placed into a function is:
Amount = principal * (pow((1 + rate / 100), time))
Total = Amount + principal
This allows for cleaner code and the ability to easily calculate compound interest for different values without duplicating code.