Page 280 - Computer Science V2.0 Class 11
P. 280
Program 10.9 Write a function called interestRate(nYears) that computes the rate of interest according to the
following table:
Time Rate of Interest (in percent)
Less than 3 years 4
Between 3 (inclusive) and 5 years 6
For all other values 8
To write a program (Program 10.9) to compute simple interest for the principal amount and the time period in years,
first we develop a function interestRate() to compute the rate of interest applicable to the number of years for
which the money is deposited.
01 '''
02 Given principal and time, to compute simple interest
03 Principal and time are provided by the user interactively
04 '''
05 # Approach: Develop a function to compute rate of interest
06 def interestRate(nYears):
07 """
08 Objective: To compute the rate of interest as per rules:
09 nYears >= 5, @8%,
10 3 <= nYears <5, @6% nYears<3, @4%
11 Inputs:
12 nYears : deposit period
13 Return value: rate: rate of interest"""
14 if nYears < 3:
15 rate = 4
16 elif nYears >= 3 and nYears <5:
17 rate = 6
18 else:
19 rate = 8
20 return rate
21
22 principal = float(input("Enter Principal Amount : "))
23 time = int(input("Enter time period in Years: "))
24 rate = interestRate(time)
25 simpleInterest = (principal * rate * time)/100
26 print("Principal:", principal)
27 print("Rate of Interest:", rate)
28 print("Simple Interest:", simpleInterest)
Sample Output:
>>> Enter Principal Amount : 3000
>>> Enter time period in Years: 4
Principal: 3000.0
Rate of Interest: 6
Simple Interest: 720.0
Program 10.10 Write a function scholarship(percentage, annualIncome) that computes the amount of
monthly scholarship to be awarded to a student, based on percentage and annual income.
Percentage Annual Income Scholarship
<40 Not applicable Nil
>=40 and <50 <65000 2000 per month
>=65000 Nil
266 Touchpad Computer Science (Ver. 2.0)-XI

