how to calculate simple interest in python code example
Example 1: python program for simple interest
principle=float(input("Enter the principle amount:"))
time=int(input("Enter the time(years):"))
rate=float(input("Enter the rate:"))
simple_interest=(principle*time*rate)/100
print("The simple interest is:",simple_interest)
Example 2: simple interest calculator using python
def Interest():
principal = input('Enter the principal: ')
rate = input('Enter the rate: ')
time = input('Enter the time: ')
Simple = ( (int(principal) * int(rate) * int(time)) / int('100'))
print('S.I. = ' + str(Simple))
def Principal():
rate = input('Enter the rate: ')
time = input('Enter the time: ')
interest = input('Enter the simple interest')
principal = ( (int('100') * int(interest)) / (int(rate) * int(time)))
print = ('Principal = ' + str(principal))
def Rate():
time = input('Enter the time: ')
interest = input('Enter the simple interest')
principal = input('Enter the principal: ')
rate = ( (int('100') * int(interest)) / (int(principal) * int(time)))
print = ('Rate = ' + str(rate))
def Time():
interest = input('Enter the simple interest')
principal = input('Enter the principal: ')
rate = input('Enter the rate: ')
time = ( (int('100') * int(interest)) / (int(principal) * int(rate)))
print = ('Time = ' + str(time))
question = input('What do you want to find: ')
if question == 'interest':
Interest()
elif question == 'principal':
Principal()
elif question == 'rate':
Rate()
elif question == 'time':
Time()
else:
print('That is not a valid value mate. ')