Page 260 - Computer Science V2.0 Class 11
P. 260
userInputs()
Output:
Enter two numbers
Number 1 : 90
Number 2 : 6
Addition Operation
The sum is 96
Multiplication Operation
The product is 540
Subtraction Operation
The difference is 84
Division Operation
The quotient is 15 and the remainder is 0
Note that the user-defined functions are executed in the order of their respective function call statements and not in order of
their sequence of definition (difference(), product(), addition(), divide()). Also, note that each function contains the docstring that
describes its objectives, data to be accepted and return values.
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): Modules make the code reusable.
Reasoning(R): In a Python program, the functions of a module may be called even before the module is imported.
2. Assertion(A): A Python module typically provides several functions to perform operations on data.
Reasoning(R): Once a module is imported, we can use all the functions defined in the module by the preceding function
name by the name of the module and a dot(.) operator.
3. Assertion(A): The statement, sqrt(25) may not lead to error.
Reasoning(R): The function sqrt() can be used without preceding it with module name math that contains it, if it has
been imported using a statement like:
from math import sqrt
Ans. 1. c 2. b 3. a
Case-based Questions
1. Lawrence wants to implement Heron's formula to calculate the area of a triangle. He wants to create a Python program
that accepts three sides of a triangle as an input, and then calculates and displays the area using Heron's formula as given
below:
s = (side1+side2+side3)/2
Area = square root (s(s-side1)(s-side2)(s-side3))
Ans. import math
def areaHeron(side1, side2, side3):
'''
Objective: To compute the area of a triangle using Heron's formula
Input Parameters: side1, side2, side3 - numeric value
246 Touchpad Computer Science (Ver. 2.0)-XI

