Button to randomly choose angle from list

Apologies if this has been discussed but I couldn’t find an answer in the forum. I have a list of angles in a graph. Can a button be pushed to choose an angle randomly instead of refreshing the graph?


https://teacher.desmos.com/activitybuilder/custom/6019fb24c5d1dc4fc46f9f53

You can create a random integer seeded by the button pressCount. Take the .random off the list, and change to a=a_ngle[i]

In the graph CL:

seed=yourButtonName.pressCount
r=randomGenerator(seed)
number(`i`): r.int(1,16)  

Using a ‘seed’ in a randomGenerator serves the same purpose as refreshing a graph. Any time seed changes, that number refreshes, so here we’re using the pressCount to change it.

1 Like

This is similar to Daniel’s method, but you can seed within the graphing component too. Use this in the CL:

number(`P_{ress}`): button.pressCount

Then adjust your first line in the calculator to look something like this:


The first argument random() is the set of numbers to choose from, the second is how many to choose, and the third is the variable that will reseed the random choice.

1 Like

I like the use of min( ), I’ve just thrown [1] at the end to use the first (and only) element in the list.

Thank you both for your replies. I think I’m wrapping my head around both methods.