Page 226 - Computer Science V2.0 Class 11
P. 226
Input Parameters: radius: numeric values
Return Value: area of circle: numeric value
'''
#Approach: Formula used: area = pi x r^2
area = 3.14 * radius**2
return area
3. Write a function that takes the temperature in Celsius as an input and returns the equivalent temperature in Fahrenheit.
def celsiusToFahrenheit(celsius):
'''
Objective: To convert temperature in celsius to fahrenheit
Input Parameters: celsius: numeric values
Return Value: fahrenheit: numeric value
'''
#Approach: Formula used: fahrenheit = (celsius × 9/5) + 32
fahrenheit = (celsius * 9/5) + 32
return fahrenheit
4. Write a function that takes principle, rate of interest, the time duration in years, and the number of times interest is applied
per year as an input and computes the compound interest.
def interest(principal, rate, time, numTimes):
'''
Objective: To determine compound interest
Input Parameters:
principal- numeric value denoting principal amount
rate - numeric value denoting rate of interest in % per annum
time - numeric values indicating time period in years
numTimes - number of times interest is applied per year
Return value: float-simple interest
'''
#Approach: Formula:CI = principal(1 + rate/numTimes)^(numTimes*time)
compoundInterest = principal*(1 + rate/numTimes)**(numTimes*time)
return compoundInterest
Assertion and Reasoning Based Questions
The following questions are assertion(A) and reasoning(R) based. Mark the correct choice as
a. Both A and R are true and R is the correct explanation of A
b. Both A and R are true and R is not the correct explanation of A
c. A is true but R is false
d. A is false but R is true
1. Assertion(A): Multiple functions can be integrated to solve a complex problem.
Reasoning(R): Once a function has been defined, it may be called several times from different parts of the program.
2. Assertion(A): eval() is a built-in function.
Reasoning(R): A built-in function is a pre-defined function in Python.
3. Assertion(A): In the statement, round(123.456, 2), 123.456 and 2 are arguments.
Reasoning(R): Arguments are the input values given to a function.
Ans. 1. b 2. b 3. b
212 Touchpad Computer Science (Ver. 2.0)-XI

