Page 73 - IPP-11
P. 73

Example 6: Write a Python code to calculate simple interest and amount payable by inputting
               the value of principal amount and rate from the user for a time period of 5 years.
               (Formula used: Simple Interest = Principal * Rate * Time/100)






























               3.15 DEBUGGING

               Apart from computer programs that we code, an exception or error or unusual condition can
               occur  even  in  our  daily  life.  Consider  a  real-life  scenario—you  leave  your  house  for  office
               by driving a car. On the way, the tyre gets punctured and you are forced to stop the car and
               replace the tyre. So, in this scenario, the punctured tyre is the exception which has occurred
           Supplement – Informatics Practices with Python–XI
               unexpectedly. In such situations, we are required to carry along a spare tyre so that we can
               change  the  punctured  tyre  then  and  there  only  and  can  continue  with  our  journey,  which  is
               described as exception handling.









                         Normal Flow                    Exception                   Exception Handling


               Likewise, when we are browsing a webpage and that webpage is unreachable because there is
               no network connection or that there is no microphone available to create an audio recording—
               these are examples of exceptions or errors.

               Sometimes  an  application  can  recover  from  an  error  and  still  provide  normal,  expected
               behaviour, sometimes errors get reported to the user, sometimes they get logged to a file, etc.
               It depends on the specific error and the application. Same is applicable in the field of computer
               programming also.

               Most application codes written for developing applications have errors in them. When your
               application suddenly freezes for no apparent reason, that is usually because of an error. But
               we all understand that programs have to deal with errors.

            3.4
   68   69   70   71   72   73   74   75   76   77   78