Ask Your Question
0

interact variables work differently

asked 2020-10-29 02:07:48 +0200

cybervigilante gravatar image

This interact works but I'm unclear why I only need n in the body of the function, but ymax alone fails. I have to make it ymax=ymax. They should both work the same.

@interact
def _(n=(1,20),ymax=(50,200)):
    show(plot([.5*x^2,x^2,2*x^2],-n,n,legend_label=[".5*x^2","x^2","2*x^2"],aspect_ratio=.2),ymax=ymax)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-02 14:03:10 +0200

slelievre gravatar image

This is because of the difference between positional arguments and keyword arguments in Python functions.

More detail can be found in the Python documentation

Tutorials can also be found by querying web search engines for [ positional arguments keyword arguments Python ].

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-10-29 02:07:48 +0200

Seen: 208 times

Last updated: Jan 02 '21