Inserting random numbers into table

#1

How does one code so as to insert random numbers into a table?

In this activity (Testing version of Feed the Shark • Activity Builder by Desmos), I would like to do the above in screen 2. I am able to generate appropriate values in a Note component, which requires students to type the results into the table. I would like to eliminate that step.

Here is what I have tried so far…
#Instantiate the randomGenerator. Assign it to a variable.
r = randomGenerator()
#Generate random values for initial angle, initial velocity, and initial height
#and populate table
a=r.int(15,75)
v=r.int(10,75)
h=r.int(0,50)

initialCellContent(2,1): “${a}”
initialCellContent(2,2): “{v}”
initialCellContent(2,3): “{h}”

The above code gives no errors, but also no table entries.
Can this be done?

#2

Did you want the same values that are in the note to also be in the table? If so, I would suggest to name the note component (I named it note2) and then in the table component, enter something like this:

initialCellContent(1,1): "${note2.script.a}"
initialCellContent(1,2): "${note2.script.v}"
initialCellContent(1,3): "${note2.script.h}"

I also noticed that nothing was showing up in your table because you have labelled it for the second row, which doesn’t exist. The header row is actually row 0, so if you use what is shown above, that should work out!

#3

Thank you.

I knew that I was doing something wrong on a basic level. It turned out to be that mis-labeling of the rows.