Ask Your Question
1

initializing value in @interact

asked 8 years ago

srobbert gravatar image

I am a new Sage user in the process of determining what aspects of previously utilized calculus Maple labs can be converted to Sage. The @interact feature is really interesting. How do I set up an @interact code so that a default value is used for the first use of the program?

My code to create a secant line plot allows the use to enter one input value (x_0) and select a function from a list prior to sliding an h value to modify the image. When the program is first run, the x_0 value shows as *None and I get error messages until I enter a number in place of None. Then the code works fine. Since this potentially is for students, I'd like to minimize the error messages...

Any help would be appreciated.

P.S. I tried to copy and paste my code (and also a screen shot image) into this box, but I am unable to copy from the VM into this program. Did I say I was a new VM user, too? Sigh.

Preview: (hide)

Comments

And if you are the user I think you are, you have alternate means of reaching this particular Sage fan :)

kcrisman gravatar imagekcrisman ( 8 years ago )

Thanks! This worked perfectly!

srobbert gravatar imagesrobbert ( 8 years ago )

In that case, just click the "accepted" check mark so that others know it was answered - I converted my comment into an answer.

kcrisman gravatar imagekcrisman ( 8 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

kcrisman gravatar image

I'm not sure it's possible not to have a default value! See e.g. this one - you just do n=5 or x_0=3or whatever. http://sagecell.sagemath.org/?z=eJxzy... If that's not what you meant, then you'll probably have to show us a sample to be able to help further.

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

1 follower

Stats

Asked: 8 years ago

Seen: 376 times

Last updated: Oct 04 '16