Simple Interest
Python
Easy
2 views
Problem Description
Principal P, rate R (in percent), and time T (in years) are provided. Output simple interest = (P*R*T)/100. If result is integer, output without decimals else output up to 2 decimals.
Input Format
One line: P R T.
Output Format
One line: interest.
Official Solution
import sys
s=sys.stdin.read().strip().split()
if not s: sys.exit(0)
P=float(s[0]); R=float(s[1]); T=float(s[2])
val=P*R*T/100.0
if abs(val-round(val))<1e-9:
sys.stdout.write(str(int(round(val))))
else:
sys.stdout.write(f"{val:.2f}")
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!