The bear hunt

repetitive-storyThis challenge is inspired from Michael Rosen and Helen Oxenbury’s children book “We are going on a bear hunt”. In this story, a family skids down a grassy slope, swishes across a river, sludges through mud and finally sees a bear who chases them all the way back to their home.

This story is based on a repetitive verse where the same verse is repeated several times and each time only a few words are changed.

So let’s see how we could apply our programming skills to print the words or lyrics of a repetitive story or song.

Learning Objectives


In this post we will investigate how to use a subroutine do write code more efficiently. We will also pass parameters to our subroutine.

You will also use string concatenation techniques to join two strings together.

Investigate the code below. See how we have defined a subroutine called printVerse() and used two parameters for this subroutine: obstacle and onomatopoeia (a word that represents a sound: e.g. splosh).

Challenge #1


Using a similar approach write a piece of code to print the lyrics of the following song:

    Five little speckled frogs
    Sat on a speckled log
    Eating some most delicious bugs – yum, yum
    One jumped into the pool
    Where it was nice and cool
    Now there are four green speckled frogs – glub, glub.

    Four little speckled frogs
    Sat on a speckled log
    Eating some most delicious bugs – yum, yum
    One jumped into the pool
    Where it was nice and cool
    Now there are three green speckled frogs – glub, glub.

    Three little speckled frogs
    Sat on a speckled log
    Eating some most delicious bugs – yum, yum
    One jumped into the pool
    Where it was nice and cool
    Now there are two green speckled frogs – glub, glub.

    Two little speckled frogs
    Sat on a speckled log
    Eating some most delicious bugs – yum, yum
    One jumped into the pool
    Where it was nice and cool
    Now there are one green speckled frogs- glub, glub.

    One little speckled frogs
    Sat on a speckled log
    Eating some most delicious bugs – yum, yum
    One jumped into the pool
    Where it was nice and cool
    Now there are no green speckled frogs – glub, glub.

Challenge #2


Using a similar approach write a piece of code to print the words of the “10 ladybugs” story by Melanie Gerth and Laura Huliska-Beith:

    Ten little ladybugs sitting on a vine,
    along came a butterfly – then there were…

    Nine little ladybugs skipping on a gate,
    along came a caterpillar – then there were…

    Eight little ladybugs looking up at heaven,
    along came a bird – then there were…

    Seven little ladybugs resting on sticks,
    along came a grasshopper – then there were…

    Six little ladybugs flying near a hive,
    along came a bumble bee – then there were…

    Five little ladybugs sleeping by the shore,
    along came a fish – then there were…

    Four little ladybugs climbing up a tree,
    along came a turtle – then there were…

    Three little ladybugs drinking up dew,
    along came a duck – then there were…

    Two little ladybugs basking in the sun,
    along came a frog – then there was…

    One little ladybug sitting all alone,
    along came a breeze – then she was HOME!

Did you like this challenge?

Click on a star to rate it!

Average rating 4.4 / 5. Vote count: 5

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,