Ask Your Question

# How to decrease the iteration step from 1 to 0.1?

@interact
def _(a=((0.1)..(5.00))):
...
show(pl1+pl2+pl3+pl4);


I would like 'a' to be iterated by the step 0.1, and not 1.

How can I achieve this?

edit retag close merge delete

## 2 Answers

Sort by ยป oldest newest most voted

Here's one approach, which works by giving Sage enough values that it can guess what step you want:

sage: (0.1, 0.2, .., 0.5)
<generator object ellipsis_iter at 0x11bce0fa0>
sage: list(0.1, 0.2, .., 0.5)
[0.100000000000000, 0.200000000000000, 0.300000000000000, 0.400000000000000, 0.500000000000000]

more

You can also specify the details using the command slider. The syntax is:

slider(a,b,step,start_value)

For example, you might have the following:

@interact
def _(a=slider(0.1,5.0,0.1,3)):
print a


This defines a slider with values from 0.1 to 5 that steps by 0.1, and the interact will launch with the slider set to 3.

more

## Your Answer

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

Add Answer

## Stats

Asked: 2012-05-27 20:43:01 +0100

Seen: 381 times

Last updated: May 28 '12