Section 6.9 Debugging of your textbook lists three possibilities to consider if a function is not working. Describe each possibility in your own words. Define "precondition" and "postcondition" as part of your description. Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it. The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within the code. For any descriptive type question, Your answer must be at least 150 words.
Section 6.9 Debugging of your textbook lists three possibilities to consider if a function is not working.
- Describe each possibility in your own words.
- Define "precondition" and "postcondition" as part of your description.
- Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.
The code and its output must be explained technically whenever asked. The explanation can be provided before or after the code, or in the form of code comments within the code. For any descriptive type question, Your answer must be at least 150 words.
When a function is not working, there are three possibilities to consider:
-
The function is not being called: In this case, the function is defined correctly, but it is not being called. This can happen if the function is not included in the main code or if there is an error in the code that is supposed to call the function.
-
The function is being called, but not with the correct arguments: In this case, the function is being called, but the arguments passed to the function are not correct. This can happen if the number of arguments passed to the function is incorrect or if the data type of the arguments is not as expected by the function.
-
The function is being called with correct arguments, but the function is not working as expected: In this case, the function is being called with the correct arguments, but the function is not producing the expected result. This can happen if the function has a logical error or if the function is not meeting its preconditions or postconditions.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps