0% found this document useful (0 votes)
70 views3 pages

Debugging Unit 3

Debugging a large program can be facilitated by breaking it into smaller functions, which serve as checkpoints. When a function fails, it may be due to violated preconditions, postconditions, or issues with the return value. Properly checking function arguments and using print statements can help identify the source of the problem.

Uploaded by

munyendoadam9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views3 pages

Debugging Unit 3

Debugging a large program can be facilitated by breaking it into smaller functions, which serve as checkpoints. When a function fails, it may be due to violated preconditions, postconditions, or issues with the return value. Properly checking function arguments and using print statements can help identify the source of the problem.

Uploaded by

munyendoadam9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Debugging

Breaking a large program into smaller functions creates natural checkpoints for debugging.

If a function is not working, there are three possibilities to consider:

 There is something wrong with the arguments the function is getting; a precondition is violated.

These are conditions that must be true before executing a function.

Outputs

In this example, the precondition is the denominator, it should not be zero. If this precondition is
violated, the function prints an error message and returns none.

 Another possibility is that there is something wrong with the function; postcondition is violated

From the book “Think Python by Allen Downey, If the parameters look good, add a print statement
before each return statement this describes postcondition.
Outputs

 There is something wrong with the return value or the way it is being used.
References:

https://greenteapress.com/thinkpython2/thinkpython2.pdf

You might also like