Respuesta :
Answer:
Explanation:
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. There is something wrong with the function; a postcondition is violated. There is something wrong with the return value or the way it is being used.
a. precondition
A precondition is a prerequisite. It's the thing that has to happen before something else happens. ... When it's a verb, precondition means to prepare something (or someone).
b)a postcondition
A postcondition is the states the system can be in after the use case has ended. Consider the following: The states described by pre- or postconditions should be states that the user can observe. "The user has logged on to the system" or "The user has opened the document" are examples of observable states.
c)As in any programming language, "return value" means the value that is returned by any sub-routine. All subroutines need not return values, sometimes return void (means nothing). Return values often indicate something about the completion of the task or result of an operation.
When you debug a code, it means you locate and correct the error(s) in the code. The three possibilities of a function not working properly are:
- Invalid arguments
- Incorrect function operation
- Incorrect return value or return type
Invalid arguments
This arises when the number of parameters does not match with the number of arguments passed to the function.
This is also referred to as violation of precondition
An example in python is as follows:
def add2num(a,b):
return a + b
add2num(5)
The above function receives 1 parameter, instead of 2
Incorrect function operation
This arises when the function does not perform the required operation.
This is also referred to as violation of post-condition
An example in python is as follows:
def squareNum(a):
return a * 2
The above function returns twice a number, instead of its square.
Incorrect return value or return type
This arises when the function returns a different value or data type, different from what it is expected to return
An example in python is as follows:
def squareNum(a):
sq = a**2
return sq
The above function is expected to return the square of a number, but it returns the number itself.
Read more about debugging at:
https://brainly.com/question/23527739