Page 124 - Trackpad_V5_Book 8
P. 124

Body of the function: The body of the function contains Python statements that make our
              function perform the required task. Syntax of creating a function is:

              def < name of the function > (list of parameters)

                        <body>


            Calling a function
            A function can be called anytime from other functions or from the command prompt after the

            definition. For calling a function, we type the function and pass the parameters. For example:
            Program 2: To call a function.


                            def my_function():                                  Name of a function



                                  print (“Hello”)                                Body of a function



                            my_function()                                        Function call




            Program 3: To print a string by calling a function.
















            You will get the following output:




















                 PURE        1.4% of all  websites  on the Internet use  Python  as a server-side programming
                 FACT        language.






            122   Pro (Ver. 5.0)-VIII
   119   120   121   122   123   124   125   126   127   128   129