Random Numbers with Exclusions

I have a random number generator set up to randomly pick an element off of the Periodic Table as shown below:

r=randomGenerator()

AtomicNumber = r.int(1,118)

Is there a way I can exclude sets of element?
For example, can I exclude numbers 21-30 and 39-48 in this rand. num. generator?

A little easier in a graph (which you could just hide)

#random number set in CL
n=5
#Elements
E=join([1...20], [31...38], [39...118])
#random element 
A=E.random(1,n)[1]

If you don’t use the n to “seed” the list, students will all have the same random element.

The code is not liking the brackets.
Here is the activity: Ions Practice • Activity Builder by Desmos

The PeriodicInfo “graph” is where all of the content is located.

Slides 1-4 have different domains, like (1,20) or (31,38) for example.
Slide 5 is where I tried to implement the code you suggested, but no luck.

That code works in the actual graph, not the CL for the graph.

It works perfectly :tada:
Thank you so much!

If you have a spreadsheet of the elements you want and their corresponding values (here’s one I found online), you can copy/paste numeric values into a table in a Desmos graph. Then, if you just choose a random number from (1…length(List)), you could just reference that element from each attribute.

Here’s an example using 1-20 from the linked spreadsheet (I hid columns with nonnumeric data):

Oh wow, thank you for this!

I’m still new to the CL and am not super familiar with how useful the graph can be. I struggle going back and forth between the two.

You can’t manipulate lists with the CL, and generally calculations are easier in graphs.

One big thing that CL can do that the graphs can’t is randomize for each student. That’s why in my original example you’d define n in the CL, because it would be different for each student. Using that value to “seed” your lists in your graphs makes them unique for each student, when they wouldn’t be otherwise.

Gotcha. That makes sense.
I also discovered that clicking the “Play” button would randomized the number on consecutive slides.
Found that out after my student kept getting the same problem 10x in a row!