# Button to randomly choose angle from list

**URL:** <https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543>\
**Category:** Questions\
**Created:** [February 3, 2021, 3:45am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543 "2021-02-03T03:45:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stacie\_Bender](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/stacie_bender/32/614_2.png) [@Stacie\_Bender](https://cl.desmos.com/u/Stacie_Bender)\
**Post date:** [February 3, 2021, 3:45am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543/1 "2021-02-03T03:45:15Z")

</div>

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?

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/d/d8b2f24213bfac3ce0d9bb9d7aff64f39fc0db39.png)  
[https://teacher.desmos.com/activitybuilder/custom/6019fb24c5d1dc4fc46f9f53](https://teacher.desmos.com/activitybuilder/custom/6019fb24c5d1dc4fc46f9f53)

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 3, 2021, 8:01am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543/2 "2021-02-03T08:01:04Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [February 3, 2021, 11:15am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543/3 "2021-02-03T11:15:17Z")

</div>

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

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

```

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

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/1/1000b9166a3b755a5ec04d664924f43f7895adf3.png)  
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.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [February 4, 2021, 1:20am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543/4 "2021-02-04T01:20:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Stacie\_Bender](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/stacie_bender/32/614_2.png) [@Stacie\_Bender](https://cl.desmos.com/u/Stacie_Bender)\
**Post date:** [February 4, 2021, 3:54am UTC](https://cl.desmos.com/t/button-to-randomly-choose-angle-from-list/2543/5 "2021-02-04T03:54:46Z")

</div>

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