Founding Batch Offer ยท HLD ยท LLD ยท System Design at โ‚น799 until 30 Nov

Simple Interest Calculator

Calculate simple interest and amount with floats. Students convert an annual percent rate, keep interest separate from principal, and format monetary examples.

BeginnerPhase 6 - Category 5: Real-World Logic ProblemsExample 4 of 15
simple-interest-calculator.py
1# Take inputs
2principal = float(input("Enter principal: "))
3rate = float(input("Enter rate (%): "))
4time = float(input("Enter time (years): "))
5
6# Calculate
7interest = (principal * rate * time) / 100
8amount = principal + interest
9
10print(f"Simple Interest: {interest:.2f}")
11print(f"Total Amount: {amount:.2f}")

Output

Enter principal: 10000
Enter rate (%): 5
Enter time (years): 2
Simple Interest: 1000.00
Total Amount: 11000.00

In this one

  • Convert percentage rates
  • Separate interest and balance
  • Understand no-compounding assumptions

How it works

  1. 1

    Read principal, rate, and years.

  2. 2

    Calculate principal * rate * time / 100.

  3. 3

    Add principal and display interest and amount.

Edge cases

What if time is zero?

What if time is zero?

Interest is zero and amount equals principal.

Are negative inputs rejected?

Are negative inputs rejected?

No. The code applies the formula without financial input validation.

What's going on

interest is principal * rate * time / 100. The division converts a percentage such as five into its fractional rate.

amount adds the interest back to the original principal. With principal 1000, rate five, and time two years, interest is 100 and amount 1100. This does not compound: interest is not added to the base during the period. Float formatting is illustrative, not accounting-grade decimal arithmetic.

What if time is zero? Interest is zero and amount equals principal.

Are negative inputs rejected? No. The code applies the formula without financial input validation.

Quiz

Tap an option. The answer stays hidden until you pick.

Question 1

What distinguishes simple interest here?

Pick an answer to check it.

Question 2

What if time is zero?

Pick an answer to check it.

Questions people ask

What if time is zero?

Interest is zero and amount equals principal.

Are negative inputs rejected?

No. The code applies the formula without financial input validation.

What distinguishes simple interest here?

Interest uses the original principal.