Page 155 - TP_Plus_v2.2_Class_8
P. 155

10                          Functions and String




                                                                  in Python










                     Let’s surf

                         Functions                                    String
                         Some More Programs




                  Let’s PLug-in                                                                 Century   #Critical Thinking
                                                                                                   21 st
                                                                                                  Skills
                    Write Python code to add first five natural numbers.

                    _____________________________________________________________________________________
                    ____________________________________________________________________________________

                    ____________________________________________________________________________________

                    ____________________________________________________________________________________
                    ____________________________________________________________________________________






                        FUNCTIONS


                 A function is a block of organised and reusable code designed to perform a single or related set
                 of actions. Functions receive data in the form of arguments and use it to execute a specified set of
                 statements and produce an output.

                      Features of Function

                 Functions are the basis of procedural programming. Some important features of functions are:
                    A  program is  divided  into  small modules  and  each  module  performs some  specific  task.  Each
                   module can be called as per the requirement.
                    We can call a function as many times as required. This saves the programmer time and effort to

                   rewrite the same code again. Therefore, it also reduces the length of the program.
                    Dividing a bigger program into smaller functions makes the program more manageable. It makes
                   debugging easy and makes the code efficient, both in terms of time and memory.





                                                                                      Functions and String in Python  153
   150   151   152   153   154   155   156   157   158   159   160