Write a program in Python to input Principle Amount, Rate, Time and a choice
from the user. If the choice inputted is 1, calculate the Simple Interest and print it.
If the choice inputted is 2, calculate the Compound Interest and print it.
Simple Interest = P*R*T/100
Compound Interest=P*(1+R/100)t

Respuesta :

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

P = float(input("Principal Amount: "))

R = float(input("Rate: "))

T = float(input("Time: "))

This line prompts user for option (1 for Simple Interest, 2 for Compound interest)

option = int(input("1 for Simple Interest, 2 for Compound interest: "))

If option is 1, simple interest is calculated

if option == 1:

    Interest = (P * R * T)/100

    print("Interest: "+str(Interest))

If option is 2, compound interest is calculated

elif option == 2:

    Interest = P * (1 + R/100)**t

    print("Interest: "+str(Interest))

If option is neither 1 nor 2, Invalid Selection is printed

else:

    print("Invalid Selection")