The not-so-random story

Amit Dhakulkar and Ravi Sinha

How many of us remember when we were introduced to random numbers? Was the experience profoundly engaging? We think not, as in most curricula, random numbers are introduced in a boring and abstract way that makes them unlikable. The term “random” itself has negative connotations. When there is no focus to a talk we say it is “random talk”, and for movement without a purpose we say “moving randomly”. But just because something is random, it does not mean it is meaningless. Random numbers are a very important concept in science and mathematics. Random numbers help us understand and explain several natural phenomena and are fundamental to many theories in science. Whether it’s diffusion of heat in air, or the prices of stock exchange, random numbers are all around us. They also have application in cryptography. Entropy and chaos is very much linked to randomness. In this article we use a concrete and operational approach to introduce children to random numbers.

Creating a set of truly random numbers is not a simple task and before computers, tables of random numbers (Figure 1) were devised using ingenious methods. (What methods can you think of to generate random numbers without using a computer? How about using dice or coins?) But a computer program can very quickly give us sets of random numbers in a given range.

Figure 1. A table of random numbers.

So how can we introduce random numbers to children in a fun and intuitive way? Though almost every programming language has a random number generator, not all programming languages are created for novice learners. There are certain programming languages which are specifically designed for learning. Turtle Blocks ( is one such language and is developed along the lines of LOGO, another programming language designed for learning. Turtle Blocks is a visual programming language (or a block programming language) using which learners can create programmes by simply combining pre-existing blocks. It is a Free and Open Source Software. Here we present some examples of how random numbers can be introduced to novice learners using Turtle Blocks which can lead to deeper engagements. The context for these episodes was an online engagement with Turtle Blocks, which was mediated through interactive sessions. The learners in this engagement were presented with “visual challenges” which they had to code using Turtle Blocks. In these challenges, the learners found random blocks to be a source of mystery, fascination and colourful artwork. We also show how simply using random blocks can lead to investigative projects which deal with some fundamental ideas in science. These episodes can be seen as first steps to the world of random numbers. There are questions interspersed throughout the article for readers, which provide food for thought and ideas for further enquiry.

Figure 2. Spoke wheel of single-colour alongside the pop-up colour palette which gets activated on selecting the value of the set colour block.

Let’s see how random block works. Figure 2 shows a simple code to make a mono-colour wheel. This programme first sets the pen colour of the turtle to 0 which corresponds to bright, reddish pink. Then there is a sequence of three commands within the repeat block which are meant to be iteratively executed multiple times, in this example 36 times. (Why 36 times? Why not 20 or 30 times?) The first one is the forward block which makes the turtle go 100 steps in the direction of its head. Then the back block traces back the exact path bringing the turtle back to the starting position but without changing the direction of its head. (What will happen if the head direction also changes? Do you still get the same figure with the above code blocks?). These blocks do two things – trace the path of the turtle thus making the spoke (line) and bring the turtle back to the same position without changing its orientation. And finally, we have the right block that rotates the turtle 10 degrees clockwise thus changing its orientation completing the action sequences for one loop. Now, this gets repeated 35 times more generating the mono colour spoke wheel.

Now let us make this fun. What if you want to change the colour of an individual spoke? That will require you to change the pen colour after every iteration (loop), isn’t it? To achieve this you may think of shifting the set colour block within the repeat block. But wait, there is a problem. (See Figure 3 (a)) How do you make the set colour change its value dynamically in every loop? Here, the random block comes to the rescue. We add a random block to the set colour block as an input. (See Figure 3 (b)) This makes the set colour value act like a random variable. On every iteration of the repeat block (here 36 times), set colour gets a new value automatically between 0-100 which changes the pen colour leading to the generation of a multicolour spoke! In different runs of the programme, we will get different colours in the wheel.

Figure 3. (a) Spoke wheel single-colour (b) Multi-colour spoke wheel using random block in Turtle Blocks.

Now, let us look at Figure 4. It shows programmes for generating random numbers between 0 and 50 in three different programming languages, (a) C++, (b) Python and (c) Turtle Blocks. In Figure 4(c), for a novice learner, one can “see” the appeal of the visual programming language. The range of the random block is set by default between 0 (min) to 50 (max) which can be changed by clicking on it. The blocks snap to each other like Lego blocks. Even the number blocks (in pink) on the right are detachable and can be replaced by variables which store numbers (called boxes in Turtle Blocks).

Figure 4. Programmes for generating random numbers between 0 to 50 in different languages.

Here it is useful to look at the specific affordance of Turtle Blocks that helps in forging the connection and also contrast it with the conventional way random numbers are introduced in other text-based languages. In C++ and Python, one can surely think of much more interesting ways to make the code appealing, but as one can see (Figure 4 (a) and (b)), it comes with additional overhead especially for novice learners. The context becomes inaccessible for beginners due to the complexity of the code and its abstract application. On the other hand, in Turtle Blocks, we can see how simple art can be converted into a multi-colour wheel generating a sense of awe and excitement in the process.

One is not restricted to making a wheel, but now with this new random power in their hands the learners tinkered with their codes to create fantastic designs. (Figures 5-9).

Figure 5. (a) Radial Spike (b) Colour Wheel using random blocks by Learner A.
Figure 6. Variations of Square spiral by Learner B – (a) increasing radius (b) denser with fixed radius.
Figure 7. (a) A snail shell (b) flowers using random block by Learner C.
Figure 8. A flower with colourful petals by Learner D.

The learners understood the fact that using the random block will result in a rainbow effect in their artworks. Learner A is aware of using the set colour block in combination with random. Learners B and C, both have incorporated “variable” in combination with other blocks. This led to parameterization of the code. Learner C also incorporated the random, set colour, store-in and loops (see Figure 7 (a)) to create a snail shell. Learner D’s motivation to make the artwork in Figure 8 is inspired by colourful petals of a flower.

Figure 9 is a good example of how real-life experiences can trigger innovative challenges and solutions and foster a deeper level of engagement. Random seems to have played a key role in forging this relationship which involves tinkering and exploring till one finds a working solution and there is no single unique solution. Many such episodes exist, which are intimately linked to what learners find interesting and investigation worthy.

But creating multi and random-coloured graphics are not the only uses of the random block. One can create a random walk very easily. Random walk is an important concept in physics. The first manifestation of the random walk was discovered in 1827 in the form of Brownian motion named after its discoverer Robert Brown. (Do you know what causes the Brownian motion?) Let us see how we can create a Brownian motion or a random walk in Turtle Blocks. The movement of the turtle is controlled by two numbers: its heading (the direction in which it is oriented) and its forward or backward movement (the number of steps it has to travel). We can assign a random block to both of them and put them in a loop (Figure 10 (a)). With each run of the programme, one will get a different shape of the path. (Why do we not get the same shape again?) (What do you think will be the effect of increasing the range of values for the forward block or decreasing the range of values for the set heading block? How will you find the total distance travelled by the turtle? Total Displacement? Average step size? What other investigations can you think of?)

Figure 10. Using the random block to create a “random walk”.

And this is just the beginning, random block can be used in a variety of ways in combination with different blocks to construct amazing things. There is no limit to the creativity and tinkering that is possible by using the blocks in ingenious ways. The modular design of the blocks to be interoperable makes them flexible and easy to use as seen from the learners’ examples.

This approach to random numbers in many ways is contrasting to first defining a random number and then working towards its applications which are often abstract. Instead, in the case of Turtle Blocks, a concrete, operational and intuitive definition of random numbers is provided in the form of constructing digital artefacts with varying colours and shapes. This allows the random numbers instead of being abstract mathematical entities to be concretized in forms which can be used in the construction of knowledge by the learners. Random numbers thus become “objects to think with”. Do you think your students will enjoy playing with random numbers? How will you use random blocks in your classroom?

If you have any more ideas, suggestions or experiences to share, feel free to reach out to us! You might also like to explore the design challenge wiki curated by us here:

The authors would like to thank all the children and their parents who encouraged participation in the pilot study. The authors would also like to thank all mentors who nudged the participants towards creative pursuits from Gnowledge Lab, HBCSE.

Amit Dhakulkar is with the Research Unit Self-Directed Learning, Faculty of Education, North-West University, Potchefstroom, South Africa. He can be reached at [email protected].

Ravi Sinha is with the Gnowledge Lab, Homi Bhabha Centre for Science Education, Tata Institute of Fundamental Research, Mumbai. He can be reached at [email protected].

Leave a Reply