Ask Your Question
0

interact variables work differently

asked 4 years ago

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)
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

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 ].

Preview: (hide)
link

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: 4 years ago

Seen: 293 times

Last updated: Jan 02 '21