Ask Your Question

Revision history [back]

The reason is the following: the notebook and command line interface, when they are evaluating input, at the end they always output the value of the last line in the input, if it is not None.

So indeed, if you enter matrix_plot(5*A) directly, you get your plot because it is the value of that line.

When you enter f(5), the body of the function is executed as it should be, but this function body does not explicitly return any value, so the default value None is returned, which results in no output.

You probably meant to write:

def f(n):
    return matrix_plot(n*A)

or equivalently

f = lambda n: matrix_plot(n*A)