Page 96 - KEC Khaitan C8 Flipbook
P. 96

FUNCTIONS, STRING                                                                      CHAPTER


                  AND LIST IN PYTHON                                                                    B2
















                     Learning Outcomes                                                                            95%


                     The student will be able to:
                        understand the concept and syntax of a for loop.
                        understand the concept and syntax of a while loop.
                         apply jump statements (such as break, continue, and return) to alter the normal flow of program
                       execution.







                            INTRODUCTION TO PYTHON FUNCTIONS


                  It is always advisable to perform a bigger task after breaking it down into a set of manageable
                  tasks. This division enables us to manage the task in a more organised manner.

                  In a programming language, functions help us to break our program into smaller pieces or modules.

                  As our program becomes large and complex, functions make it more organised and manageable.
                  Like any other programming language, Python also allows us to use functions in a program.

                  A function can be defined as a block of reusable code that performs a specific task. This concept
                  is the central aspect on which the concept of procedural programming works.


                  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 a  specific  task.  Each

                    module can be called as needed.
                      We can call a function as many times as required. This saves the programmer the time and
                    effort by not having 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
                    simplifies debugging and makes the code efficient, both in terms of time and memory.




                   94   Premium Edition-VIII
   91   92   93   94   95   96   97   98   99   100   101