Learn about Python Program to Find Simple Interest using Function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python Program to Find Simple Interest using Function
# Program to calculate simple interest using function
#user-defined function
def calculate_simple_interest(P, R, T):
SI = (P * R * T) / 100
return SI
#inputs
P = float(input('Enter the Principal amount: '))
R = float(input('Enter the Interest rate: '))
T = float(input('Enter time: '))
simple_interest = calculate_simple_interest(P, R, T)
# print result
print('The Simple interest = %.2f' %simple_interest)
print('Total amount = %.2f' %(P + simple_interest))
Output:
Enter the Principal amount: 3000 Enter the Interest rate: 3 Enter time: 6 The Simple interest = 540.00 Total amount = 3540.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python Program to Calculate Simple Interest