Page 77 - IPP-11
P. 77

The  example  above  should  calculate  the  average  of  the  two  numbers  the  user  enters.  But
               because of the order of operations in arithmetic (division is evaluated before addition), the
               program will not give the right answer; this is known as logical error.












               As a result, you will get 5.0 as the output instead of 3.5.
               To rectify this problem, we will simply add parentheses: z = (x+y)/2














               Hence, now we will get the right result as 3.5.







           Supplement – Informatics Practices with Python–XI







                   MEMORY BYTES
                   The process of identifying and removing errors from a computer program is called debugging.
                   Trying to use a variable that has not been assigned a value gives an error.

                   Runtime errors occur during the execution of a program.
                   Irregular unexpected situations occurring during runtime are called exceptions.


               OBJECTIVE TYPE QUESTIONS
                 1.  Fill in the blanks.
                    (m)  The process of identifying and removing errors from a computer program is called ...................... .
                    Answer:  (m)  Debugging
                 3.  Multiple Choice Questions (MCQs):
                     (k)  Which of the following is a syntactically correct string?
                         (i)  “This is great !”                      (ii)  ‘she shouted ‘HELLO’ loudly’
                        (iii)  “Goodbye’                             (iv)  “This “course” is good”
                    Answer:  (k)  (i)



            3.8
   72   73   74   75   76   77   78   79   80   81   82