Answer:
P = float(input("Principal Amount: "))
R = float(input("Rate: "))
T = float(input("Time: "))
option = int(input("1 for Simple Interest, 2 for Compound interest: "))
if option == 1:
Interest = (P * R * T)/100
print("Interest: "+str(Interest))
elif option == 2:
Interest = P * (1 + R/100)**t
print("Interest: "+str(Interest))
else:
print("Invalid Selection")
Explanation:
The next three line prompt user for Principal Amount, Rate and Time
<em>P = float(input("Principal Amount: "))</em>
<em>R = float(input("Rate: "))</em>
<em>T = float(input("Time: "))</em>
<em>This line prompts user for option (1 for Simple Interest, 2 for Compound interest)</em>
option = int(input("1 for Simple Interest, 2 for Compound interest: "))
If option is 1, simple interest is calculated
<em>if option == 1:</em>
<em> Interest = (P * R * T)/100</em>
<em> print("Interest: "+str(Interest))</em>
If option is 2, compound interest is calculated
<em>elif option == 2:</em>
<em> Interest = P * (1 + R/100)**t</em>
<em> print("Interest: "+str(Interest))</em>
If option is neither 1 nor 2, Invalid Selection is printed
<em>else:</em>
<em> print("Invalid Selection")</em>