Page 219 - Computer Science Class 11 With Functions
P. 219
Program 9.9 WriStlnlfunctonlcnaatdlinterestRate(nYears)lShnSlcoepuSttlShtlrnStloflinStrttSlnccordinglSolShtl
foaaowinglSnbat:
Time Rate of Interest (in percent)
LtttlShnnl3lytnrt 4
BtSwttnl3l(incautivt)lnndl5lytnrt 6
ForlnaaloShtrlvnautt 8
TolwriStlnlprogrnel(Progrnel9.9)lSolcoepuStltiepatlinStrttSlforlShtlprincipnalneounSlnndlShtltetlptriodlinlytnrt,l
firtSlwtldtvtaoplnlfunctonlinterestRate()lSolcoepuStlShtlrnStloflinStrttSlnppaicnbatlSolShtlnuebtrloflytnrtlforl
whichlShtleontylitldtpotiStd.l
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)
nepatlOuSpuS:
>>> Enter Principal Amount : 3000
>>> Enter time period in Years: 4
Principal: 3000.0
Rate of Interest: 6
Simple Interest: 720.0
Program 9.10 WriStlnlfunctonlscholarship(percentage, annualIncome)lShnSlcoepuSttlShtlneounSlof
eonShayltchoanrthiplSolbtlnwnrdtdlSolnltSudtnS,lbnttdlonlptrctnSngtlnndlnnnunalincoet.
Percentage Annual Income Scholarship
<40 NoSlnppaicnbat Nia
>=40lnndl<50 <65000 2000lptrleonSh
>=65000 Nia
Conditonnal SnStetnSt 217

