Computer Science, asked by shubbi07, 1 month ago

Write a program to calculate simple interest by accepting principal amount from the user on

8.5 % rate of interest for 5 years.​

Answers

Answered by Anonymous
4

Simple interest - Python

What we need to do

We would take a user float input first, to accept the principal amount from the user. We know that when we want the user to type in a decimal value, we use float(input()) function.

After this, we know that the formula simple interest, so we will use simple interest formula formula. Here, we are are given with the rate, time and we will take principal amount value from the user. So, we are given with all three elements that we are required to used in formula.

We then print out the simple interest with the answer.

Why we use float() function

We use \tt{float()} function since user can also enter the decimal value, values could always have the possibility of being in decimals. If we use \tt{int()} function as the data type and a user enters a decimal value or integers, the program would result in an error. To be on the safer side, we use \tt{float()} as both integers and decimals are accepted.

\rule{300}{1}

The Program

# Takin user input

principal=float(input("Enter the principal value: "))

rate=8.5

time=5

# Now we know that, the formula for finding the simple intrest is, SI=P*R*T/100. So, by using this formula we can easily find out the simple intrest

# Using simple intrest fomula

SI=(principal*rate*time)/100

print("The simple intrest is", SI)

\rule{300}{1}

Sample Output

Enter the principal value: 5

The Simple interest is 2.125

Answered by juwairiyahimran18
0

Simple interest - Python

What we need to do

We would take a user float input first, to accept the principal amount from the user. We know that when we want the user to type in a decimal value, we use float(input()) function.

After this, we know that the formula simple interest, so we will use simple interest formula formula. Here, we are are given with the rate, time and we will take principal amount value from the user. So, we are given with all three elements that we are required to used in formula.

We then print out the simple interest with the answer.

Why we use float() function

We use \tt{float()}float() function since user can also enter the decimal value, values could always have the possibility of being in decimals. If we use \tt{int()}int() function as the data type and a user enters a decimal value or integers, the program would result in an error. To be on the safer side, we use \tt{float()}float() as both integers and decimals are accepted.

\rule{300}{1}

The Program

# Takin user input

principal=float(input("Enter the principal value: "))

rate=8.5

time=5

# Now we know that, the formula for finding the simple intrest is, SI=P*R*T/100. So, by using this formula we can easily find out the simple intrest

# Using simple intrest fomula

SI=(principal*rate*time)/100

print("The simple intrest is", SI)

\rule{300}{1}

Sample Output

Enter the principal value: 5

The Simple interest is 2.125

Similar questions