Page 69 - Digicode_AI_class_8
P. 69

Well done, you have learned to check if the number is Even or Odd!





            You can view the code of the above program in ‘Python’ by selecting ‘Python’ as an Editor.















            What Exactly are Functions?

            A function is a block of code which is made up of a set of steps that result in a single specific action.
            The  programmer  will  give  a  simple  name  to  this  specific  function,  as  giving  a  simple  name  to  a
            function, increases the chances that the set of steps can be easily reused again and again in the
            program.

            Function Parameters

            Function parameters are variables local to the function, taken as input to do a task when the function
            is called and are part of the definition. Arguments are the values that are passed on to the function
            received by the function as a parameter. A function can have more than one parameter, and in this
            case order in which arguments are passed matters.
            So, Function parameters are the names listed in the function definition and Function arguments are
            the real values passed to (and received by) the function.
            Example:

            To calculate the volume (V) of a cuboid, you need three variables length (L), breadth (B) and height
            (H). The formula to calculate the volume of a cuboid is V = L * B * H.

                                                                           Advanced MakeCode Arcade       67
   64   65   66   67   68   69   70   71   72   73   74