Ask Your Question
1

initializing value in @interact

asked 2016-10-04 14:15:45 -0500

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.

edit retag flag offensive close merge delete

Comments

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

kcrisman gravatar imagekcrisman ( 2016-10-04 14:43:46 -0500 )edit

Thanks! This worked perfectly!

srobbert gravatar imagesrobbert ( 2016-10-05 12:05:17 -0500 )edit

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 ( 2016-10-05 12:50:56 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-10-04 14:43:28 -0500

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.

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

1 follower

Stats

Asked: 2016-10-04 14:15:45 -0500

Seen: 60 times

Last updated: Oct 04 '16