Page 253 - Computer Science Class 11 Without Functions
P. 253

2.  Give all possible outputs that may be produced when the following code is executed.
                  import random
                  continents = ['Asia', 'Australia', 'South America', 'North America', 'Europe',
                    'Antarctica']
                  option1 = random.randint(2, 4)
                  option2 = random.randint(3, 5)
                  for x in range(option1, option2):
                      print(continents[x], end = '#')
             Ans:  Europe#
                  North America#Europe#
                  North America#
                  South America#
                  South America#North America#Europe#
                  South America#North America#


                   Assertion and Reasoning Based Questions


               The following questions are Assertion(A) and Reasoning(R) based questions. 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:  '''
                  Objective: To compute the area of a triangle using Heron's formula
                  Inputs: side1, side2, side3 - numeric value
                  Output: area of triangle - numeric value
                  '''



                                                                                                      Modules    251
   248   249   250   251   252   253   254   255   256   257   258