Page 75 - Code & Click - 8
P. 75

CALLING A FUNCTION
            The process of using a function at the Python prompt or in a program is known as Calling the function.
            While calling a function, we must use its correct name and pass the required number of arguments
            to it. If the function returns a value, care must be taken to store the value in a variable.
            For example, the statement to call the area_square function as described earlier in the chapter is
                   SqArea = area_square(20), or

                   >>> print(area_square(10))
                                                                                                 Experiential Learning
              Lab Activity 1
             To create a user-defined function without any arguments or return value and call it.
             1. Type the code as shown in the image in the Python Editor.












             2. Press the F5 key to execute the code. Sample output of the program is given below.














                                                                                                 Experiential Learning
               Lab Activity 2
             To create a user-defined function that takes arguments but does not return any value and call it.

             1. Type the code as shown in the image in the Python Editor.













             2. Press the F5 key to execute the code. Sample output of the program is given below.














                                                                                                                 73
   70   71   72   73   74   75   76   77   78   79   80