Page 186 - Computer Science Class 11 Without Functions
P. 186
Solution:
01 '''
02 Objective: To compute a student's result
03 Inputs:
04 percentage: percentage of the marks
05 Output:
06 Student's result – Passed or Failed
07 '''
08 passPercent = 33
09 percentage = int(input("Enter your percentage: "))
10 if percentage >= passPercent:
11 print("You have Passed")
12 else:
13 print("You have Failed")
nepatlouSpuSl1:
>>> Enter your percentage: 25
You have Failed
nepatlOuSpuSl2:
>>> Enter your percentage: 90
You have Passed
Program 8.4 WriStlnlprogrnelShnSlcoepuSttltiepatlinStrttSlforlnlprincipnalneounSlforlnltetldurntonltptcifitdlin
ytnrt.lIf Shtltetldurntonlitlfivtlorleortlytnrt,lShtlrnStloflinStrttSlitl4%;loShtrwitt,liSlitl3%.
Solution:
01 '''
02 Objective: Given principal and time, compute simple interest.
03 interest rate: 4%, if time >= 5 years, 3% otherwise
04 Inputs:
05 principal : principal value
06 time: time period
07 Output:
08 interest: simple interest as per applicable rate
09 '''
10
11 principal = float(input('Enter Principal Amount: '))
12 time = int(input('Enter time period: '))
13
14 if time >= 5:
15 rate = 4
16 else:
17 rate = 3
18
19 interest = (principal*rate*time)/100
20
21 print('Simple Interest=', interest)
NtxS,latSlutluttlProgrnel8.4lSolcoepuStltiepatlinStrttSlforlnltuelofl4000lruptttlforltetlptriodtlofltixlytnrtlnndl
Swolytnrt:
nepatlOuSpuSl1:
>>> Enter Principal Amount: 4000
>>> Enter time period: 6
Simple Interest= 960.0
nepatlOuSpuSl2:
>>> Enter Principal Amount: 4000
>>> Enter time period: 2
Simple Interest= 240.0
184 Touchpad Computer Science-XI

