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

ign8.5:ninterest(1000, 5, 2): callntonfunctonninterest()nfromnIDLE


        8.2.3 Help on a User-defined Function
        Whennweninvokenthenhelp()nfunctonnonnanuoer-definednfuncton,nitndioplayonthenfunctonnnamenalongnwithnthen
        parameternliotnandnthenfirotndoc stringn(ifnnpreoent)ninnthenfunctonnthatnappearonbeforenanynexecutablenotatemento,nforn
        example,

         >>> help(interest)
                  Help on function interest in module __main__:
                     interest(principal, rate, time)
                Objective: To determine simple interest
                Input Parameters:
                   principal- numeric value denoting principal amount
              rate - numeric value denoting a rate of interest in % per annum
              time - numeric values indicating the time period in years
              Return value: float-simple interest

               1.  Positional arguments-The arguments in a function call that necessarily appear in the same order in which the
                 formal parameters are specified in the function definition.
               2.  Formal parameters in the function definition and the arguments in a function call can have the same name.
               3.  return is a keyword that is used to return the result of computation from a function to the statement that
                 invoked the function.
               4.  In the absence of any return statement, a function returns the default value None.



             Let's Summarise


          Execution of a program with user-defined functions
          Ø n Whennanfunctionnioninvoked,nthencontrolnflownchangeonaonohownninn ign8.6.


                                         n  SequencenExecution

                                            3 def test (num):
                                            4          num = num + 1
                                            5          return num
                                            1 var = 10
                                            2 setNum = test (var)
                                            6 print (setNum)

                                  ign8.6:n lownofnexecutonninnanprogramnwithnuoer-definednfunctonon


         192   Touchpad Computer Science-XI
   189   190   191   192   193   194   195   196   197   198   199