Page 201 - Computer Science Class 11 With Functions
P. 201

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.  Aooertion(A):n Multiplenfunctiononcannbenintegratedntonoolvenancomplexnproblem.
                  Reaooning(R):  Oncenanfunctionnhaonbeenndefined,nitnmaynbencallednoeveralntimeonfromndifferentnpartonofnthenprogram.nn
               2.  Aooertion(A):n eval()nionnanbuilt-innfunction.n
                  Reaooning(R):  Anbuilt-innfunctionnionanpre-definednfunctionninnPython.
               3.  Aooertion(A):n Innthenotatement,nround(123.456, 2),n123.456nandn2narenargumento.
                  Reaooning(R):  Argumentonarentheninputnvalueongivenntonanfunction.n
             Ans.  1.nb  2.nb  3.nbn


                  Case Based Questions


               1.  Onkarnhadncreatednanprogramntonacceptntimeninnoecondonandnthenndioplaynitninnminuteonandnoecondo.nToday,nhionteachern
                  explainednthenconceptnofn unctiononinnclaoonandnaloongavenhimnthentaoknofncreatingnthenoamenprogramnuoingnuoer-definedn
                  functiono.nThenprogramnwillnacceptnthenvaluenofntimeninnoecondonpaooednaonannargumentntonthenfunctionncallednconvertTime(t).n
                  Thenfunctionnwillnthenndioplayntimeninnminuteonandnoecondo.
             Ans.  def convertTime(seconds):
                      '''
                     Objective: To convert seconds to minutes and seconds

                      Input perimeters: seconds – numeric value
                      Return Value: minutes,   seconds - numeric value
                      '''
                      minutes = seconds//60
                      seconds = seconds%60
                      return minutes,   seconds

                  tSec = int(input('Enter the time in seconds :  '))
                  minutes,   seconds = convertTime(tSec)
                  print('The time is ',   minutes,   'minutes',   seconds,   '  seconds')
               2.  Sumedhanwantontoncreatenanfunctionnthatntakeonheightninnfeetnandnincheonaonargumentonandnreturnonthenheightninncentimetero.n
                  Helpnhernwritenthenfunctionnandnthenncallnthenfunctionntonviewnthenoutput.

             Ans.  def convertHeight(feet, inches):
                      '''
                      Objective: To compute height in cms
                      Input Parameters: feet,   inches – numeric values
                      Return Value: cms- float value
                      '''

                      cms = feet * 30.48 + inches * 2.54
                      return round(cms,  2) #rounded to 2 decimal places


                                                                                        Introductonnton unctono  199
   196   197   198   199   200   201   202   203   204   205   206