
Now for your homeworkyour homework for this unit will be

statistical debugging on a mystery program.

The ideal is that you get the mystery program and the number of runs which pass or fail

and your job is to apply statistical debugging to find out

what is it in the mystery program that causes the failures.

However, this time we're going to look at another set of execution features that is not lines executed

but instead the return values of individual functions.

One of the outputs of your task could be

that the program fails whenever f returns a value that's greater than zero.

For this, you need to track the return values of individual functions

and again, the Python trace it function will do that for you.

The event is return and the return value is contained in the argument.

Plus you need to categorize the return values in multiple booklets.

I want you to use precisely three categoriesnamely less than zero, zero, and greater than zero.

For numerical values, this is straightforward.

Depending on the sign you put them into one of the three categories,

but what for non numerical values say list or strings or dictionaries or sets.

For these, you compute the length. If a string is empty, then it comes into the zero category.

If it has one character or more, then it comes into the greater than zero category.

Same goes for setsno elements, one element or more, list in dictionaries likewise.

The Boolean values false and true, also going to zero and greater than zero.

Since less than zero is frequently used to indicate some exceptional return value,

we're going to use this category for special values

such as none, not a number. as well as for exceptions.

That is if a function does not return a value but raises an exception instead,

then you categorize this in the same way as the return value that is less than zero.

What you then do is for each function you compute the five coefficient for each category

as well as for its respective complement.

What do I mean by complement? Well, let me illustrate this with an example.

So again you set up a table and count in how many runs the function f

return the value that was less than zero.

Do this for the failing runs as well as for the passing runs.

The complement here of course is any value that is greater or equal than zero

and again you count the number of runs and this is something you do for each category.

For the zero category, we check whether the return value was zero or whether it was nonzero

and finally, we do the same for the third category namely greater than zero.

Now your task will be to compute the five coefficients for all function and all categories

as well as their compliments and then to find out for the mystery program, which is the one function

whose return value category correlates the strongest with failure.

Here's your chance to apply statistics to do the debugging. Enjoy.