Chapter: Python Last Updated: 27-04-2023 16:11:19 UTC

Program:

` ````
/* ............... START ............... */
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the interest rate: "))
time = float(input("Enter the time period in years: "))
interest = principal * rate * time
print("The simple interest is: ", interest)
/* ............... END ............... */
```

Output

Enter the principal amount: 1000 Enter the interest rate: 5 Enter the time period in years: 2 The simple interest is: 100.0 In this example, the user inputs a principal amount of 1000, an interest rate of 5%, and a time period of 2 years. The program then calculates the simple interest, which is 100.0.

Notes:

- The program starts by prompting the user to input the principal amount, interest rate, and time period in years using the input() function. These values are then stored in three separate variables principal, rate, and time, respectively.
- Next, the program calculates the simple interest using the formula I = P * R * T, where I is the interest, P is the principal amount, R is the interest rate, and T is the time period in years. This is done by multiplying the principal, rate, and time variables together and storing the result in the interest variable.
- Finally, the program prints out the simple interest by using the print() function along with the text string "The simple interest is: " and the value of the interest variable.
- Overall, this program is a simple example of how you can use Python to perform calculations based on user input.

Tags

Simple interest Python program #Python Interest Calculator #Python program for simple interest