Do Challenges

So you're getting better at coding? We've got some challenges for you.

So you're getting better at coding. Maybe you've earned some CoderDojo Stirling badges. Now try some of our challenges below!

Start completing challenges today:

  1. Pick an area below that interests you. There's Fun with Scratch, Making Websites, Coding (in Python or Javascript) and Microbits.
  2. Pick a challenge that looks fun.
  3. Do it!

Newest challenge: Insult Generator, in Scratch or in Code.


Fun with Scratch

Before you start

Scratch is a nice programming language for learning how to code. If you haven't used Scratch before, you can do our Scratch badges to get started. If you have used Scratch before, pick a challenge below and do it!

Challenge: I Wanna Be a Rockstar

Make a theatre stage with a band on it: a drummer, a guitarist, a singer, and anyone else you want. When you click on a person (or their instrument), the instrument sound should play. So when you click on the drums, you hear drums!

Getting started:

  • The Sprite Library has a “Music” category with useful sprites in it.
  • The Sound Library has lots of sounds you can use. Or record your own!

More advanced: Try clicking your band members at the right time, so it sounds like a proper song!

Challenge: Bear wants Dinner

Make a story about a bear searching for his dinner. The bear should move around, and tell the following joke to a frog:

  • Bear: "Why don't bears like fast food?"
  • Frog: "I don't know: Why don't bears like fast food?"
  • Bear: "Because they can't catch it!"

Hints:

  • You can find a ‘bear’ sprite in the Scratch sprite library. Or draw your own.
  • Sprites can speak with the ‘say’ command.
  • Sprites can have a conversation (one speaks after the other) using the ‘broadcast’ and ‘message’ commands

Challenge: Maze of Insults

Create a maze game. If you collide with a wall, you get teleported to the start, and told “you clumsy oaf”!

Getting started:

  • You will need 3 sprites: a player, the maze walls, and a finish point.
  • Use the ‘touch’ sensor to work out if the player has collided with a wall. You can detect when two sprites collide, or when one sprite collides with a colour.

Challenge: Animate Your Name

Make an animation of your name, so each letter does something cool like make a sound, or move around or change colour. I’m called GREG, so the G might spin around, the R might change from red to blue, and so on. The animation should start when the Green Flag is clicked.

Getting started:

  • Add letter sprites for your name: look in the Sprite Library under Letters. So I would add G, R, E and G.
  • For each character sprite, make it do something cool when the Green Flag is clicked.

More advanced: Make the animation cooler. You could make the background change, or make a bird fly around, or make the letters do things when you click on them.

Challenge: Catching Mice

Create a game where the player gets points when the cat catches a mouse, and loses points when the cat steps in a dog-poo.

Getting started:

  • You will need lots of sprites: a cat, lots of mice, a lots of dog poo.
  • Use the ‘touch’ sensor to work out if the cat has collided with something.
  • Use a ‘variable’ to track the score.

More advanced: can you make this game two-player?

Challenge: Aquarium

Build an aquarium with fish swimming around and plants at the bottom. The fish should turn round when they hit the aquarium edge.

Getting started:

  • You will need 2 sprites to start: a fish and a plant.
  • Look in the ‘motion’ section to make the fish move.

More advanced: Add a shark into the aquarium that is controlled with the arrow keys. Make the fish run away when they bump into the shark.

Challenge: Space Miner

Make a game about a space miner:

  • There’s a solar system with planets and asteroids (small lumps of space rock).
  • There’s a space ship.
  • The player moves the space ship to collect the asteroids. The player gets one point for running over each asteroid.
  • The space ship blows up if it crashes into a planet.

Getting started:

  • You will need different sprites for the spaceship, asteroids and planets.
  • Use the ‘touch’ sensor to work out if the spaceship has collided with an asteroid or planet. You can detect when two sprites collide, or when one sprite collides with a colour.

Challenge: Hide and Seek

Make a Hide and Seek game with the Scratch Cat: the Cat will appear somewhere on the screen, then vanish after 2 seconds. 6 seconds later, the Cat will appear somewhere else on the screen, then vanish again after 2 seconds. It does this forever. The player gets one point when they click on the cat, and lose a point if they click on the background.

Getting started:

  • Use two starting sprites: the Scratch Cat and the Background. Work out how to add and remove points from a score counter when these sprites are clicked.
  • Work out how to make the Scratch Cat appear and disappear with the ‘hide’ and ‘show’ commands.
  • Work out how to change the location of the Scratch Cat to a random x and y position.
  • If you need more help, the Scratch website has ‘step by step’ instructions for making a hide and seek game. Click on ‘Explore’ at the top of the main webpage, then look for ‘Hide and Seek Game’ on the right hand side.

Halloween Challenge: Escape the Graveyard

Make a game about escaping a graveyard. You start at one side of the graveyard, and have to escape through a gate on the other side. The graveyard has grave-stones in the ground, and ghosts that move around. If you collide with a grave-stone or a ghost, you get teleported to the start.

Getting started:

  • You will need some sprites: the player, gravestones, and ghosts
  • Use the ‘touch’ sensor to work out if the player has collided with a gravestone or ghost. You can detect when two sprites collide, or when one sprite collides with a colour.

More advanced: Make the graveyard more spooky. What about making an invisible ghost appear when the player hits a gravestone? Maybe it says “boo!” (record the sound effect)

Challenge: Parachute Jump

Make a game about someone doing a parachute jump, and having to dodge moving clouds. If they hit a cloud, they lose the game.

Getting started:

  • Draw your parachutist
  • Draw some clouds - you'll need a few!
  • To make the game, put the parachutist near the top of the screen (they won't move). Now make each cloud move from the bottom of the screen to the top, and it will look like the parachutist is falling! There is a trick to this, as you want each cloud to start off-screen at the bottom, and move up until it goes off-screen at the top. When the cloud gets to the top, move it to the bottom again!:
    • To start the cloud off-screen at the bottom, set y to be less than -180 (try -200)
    • To check when the cloud has gone off-screen at the top, check if y is more than 180 (try 200)
    • Scratch doesn't like putting sprites off-screen, but you can trick it: every time you move the sprite's position (x and y), put "set size to 200%" before, and "set size to 100%" after. Strange, but this seems to work!

More advanced: make things harder, with more clouds moving randomly at different speeds. You could also keep score by counting how many clouds the parachutist dodged. Or make things look cooler by changing the background: what about thunder and lightning, or snow?

Challenge: Maths Quiz

Make a quiz where the player has to multiply random numbers together. "What's 2 times 7?". "14". "Correct!".

Getting started:

  • You'll need a sprite to ask the quiz question. For now, ask: "what's 2 times 7?"
  • Let the player enter the answer
  • Compare the player's answer against the real answer (14). If they match, the sprite should say "correct!" or "wrong!" if they don't
  • Now make the quiz question use random numbers (not just 2 and 7). This is a bit tricky:
    • You will need two 'variables' to store the random numbers
    • Scratch can pick a random number for you using the 'pick' block (look under 'operators')
    • The quiz question must use your two number variables
    • To check if the player's answer is correct, you will need to compare it against the two number variables multiplied together

More advanced: make the quiz ask 10 questions, and keep a score of correct answers. And do more fun stuff when the player gives a right answer (yay!) or wrong answer (boo!).

Challenge: Whistle for the Wind

Make a scene with a windmill (or wind turbine) and a cloud. Make the windmill turn and the cloud move across the sky. Now here's the fun bit: make the windmill turn faster the louder you whistle (or yell) into your computer's microphone. The cloud should move faster too. The louder you whistle, the stronger the wind!

Getting started:

  • Make a windmill with sails that turn: you can use "turn x degrees" (look under 'motion')
  • Make a cloud that moves across the sky
    • Use 'set x' and 'set y' to set the cloud's starting position
    • Make the cloud move using 'change x'
    • Once the cloud crosses the whole screen, move it back to its starting position (so we don't lose it off the screen!)
  • Now for the whistling bit.
    • Scratch has a 'loudness' value (look under 'sensing'). It measures how loud the noise is that your computer's microphone hears, from 0 to 100.
    • Use the 'loudness' value to change how fast the windmill turns and the cloud moves.
    • For the windmill, try "turn 'loudness' degrees"
    • For the cloud, try "change x by 'loudness'" (to make the cloud go in the other direction, multiply by -1)

More advanced:

  • Add more clouds, and make their starting position random (the y value).
  • Change the colour of the clouds as they move
  • Add a meter that shows how much electricity is generated by the windmill

Challenge: Reaction Time

Make a game that measures your reaction time: how fast you can click when Scratch cat changes from his normal orange colour to blue. At the end of the game, show your reaction time (it will be in milliseconds, which is a second divided into 1000 parts). What's the fastest you can click?

Getting started:

  • You will need a Scratch cat sprite, with a orange and a purple costume.
  • You can measure reaction time using the 'timer' block in the 'sensing' section: use 'reset timer' when you want to start timing, and assign 'timer' to a variable when you want to record the end reaction time.
  • You can also use the timer to wait a few seconds at the game start before you switch Scratch cat's costume.
  • Use different backdrops for different stages of the game: to show instructions at the beginning, to show when to click on scratch cat, and to show reaction time at the end.

More advanced:

  • Make the player pay attention: randomise the time at the game start before you change scratch cat's costume.
  • Tell the player off if they click too early (before scratch cat is purple).
  • Let the player have multiple goes, and calculate their average reaction time.

Challenge: Insult Generator

Make a Scratch program that generates random insults :-) Scratch cat first asks for your name, then insults you. Here goes..

  • "What's your name?"
  • "Greg"
  • "Hi Greg. You eat like a greasy baboon!". Or maybe "Hi Greg. You run like a purple hippo!"

Getting started:

  • You will need a Scratch cat sprite.
  • Now get Scratch cat to ask your name, and say hello ("Hi Greg"). Useful Scratch blocks:
    • 'ask and wait' under Sensing
    • 'say' under Looks
    • 'join' under Operators (used to join words together into a sentence)
  • Generating the insult is the tricky bit. Each insult is a sentence with the same structure: "Hi (Greg - name). You (eat - doing word) like a (greasy - describing word) (baboon - naming word). So we'll generate the insult by randomly picking a doing word, a describing word and a naming word, then making a sentence out of them:
    • Make a list of doing words (verbs). Use 'Make a list' under 'Data'. How about: eat, run and swim.
    • Make a list of describing words (adjectives). How about: greasy, smelly, grumpy.
    • Make a list of naming words (nouns). How about: baboon, cardboard box, dolphin.
    • Now we'll generate the insult by randomly picking a word from each of the three lists, and combining them into a sentence. To randomly pick a word, use 'item random of list-name' under Data. To combine the words into a sentence, use 'join' under Operators. You'll need to use 'join' multiple times.
    • Go make some fun insults!

Making Websites

Before you start

If you’ve never built a website before, do our badge called Get your own website on the Internet. If you have built a website before, pick a challenge below and do it!

Challenge: The Solar System

Create a website about the solar system. It will need a start page describing the solar system, and a page about every planet. You could even do pages about different space missions involving astronauts.

Hints:

  • If you find a cool webpage on the internet (about space!), you can link to it from your website.
  • You could draw your own pictures of planets, or space-ships, or aliens.
  • Can you make the website feel like space by changing colours? You’ll need to change CSS.

Challenge: Where I Live

Create a website about the place where you live. Let’s say you live in Stirling. Where is it? How old is it? What would you show someone who came to visit? What interesting things can you do there?

Getting started:

  • Create one web-page explaining what the site is about.
  • Now create extra pages about particular topics, and link to them from the main web-page.
  • You can link to other Internet web-pages that are interesting: like the Stirling wikipedia page.
  • Lots of drawings and pictures please! You can create your own or find some online (with ok licence).

Christmas Challenge: I’ve been good!

What do you want for Christmas? Let Santa (and mum, dad, gran and anyone else) know with your own website.

Your website should have descriptions and pictures of the items you want and links to where they can be bought. You could prioritise the items with a star rating to say how much you want that item, or organise it by price so everyone can find the right gift for you!

More advanced: Add some Christmas style and Christmas tunes to get everyone in the present-buying mood!

Challenge: Science!

Chemistry, computing, psychology, microbiology, astronomy…. how many types of science can you think of?

Make a guide to science: your website should have one page for each type of science. Explain what it is. Include pictures of famous scientists or discoveries, and links to other websites so that your readers can find out more.

Halloween Challenge: Haunted House

Make a website game about a haunted house. Each webpage is a room in the house, and describes the spookiness happening in the room. The links on a room’s webpage take the player to other rooms nearby.

The player starts outside the haunted house (on the website’s main page). They then choose which links to follow to take them though the haunted house, and out the back door!

Challenge: Olympics

So you watched the Olympics? There were loads of cool sports: swimming, triathlon, fencing, …

Make a website about the Olympics. You can have pages about different sports and athletes. Maybe a page about Rio de Janeiro in Brazil. Include pictures and videos (try including a youtube video). Link to other websites where your readers can find out more.

Challenge: Animal Noises

Make a webpage with lots of animal pictures. When you click on a picture ("sheep"), an alert box should pop up with the animal noise ("baa").

This challenge involves adding some javascript to your webpage. You'll need to get two parts working (do some searching online!):

  • To make something happen when someone clicks on an image, you will need an onclick attribute
  • To popup the animal noise, you will need an alert box
More advanced:
  • When the animal image is clicked, play the actual animal sound! Try searching for play a sound on click for help on how to do this.

Challenge: Baker's Shop

Make a website for Bob's Bakery.

"My name's Bob, and I run Bob's Bakery. We make lots of cakes and tasty things: chocolate cake, gingerbread men, jam doughnuts, ring doughnuts, strawberry tarts, and lots more. I'd like to start selling my cakes on the internet, so will need a website. I reckon it needs:

  • A home page, all about Bob's Bakery and our cakes. We've been baking since 1917!
  • A page for each of the cakes we sell, with details of each cake: its name, picture, price, ingredients, and a big "buy" button
  • A "contact us" page, with the address and map of our shop. Our shop is actually inside the Wallace Monument! The address is: Abbey Craig, Hillfoots Rd, Stirling FK9 5LF
I'm looking forward to what you come up with :-) Thanks, Bob"

Challenge: My Favourite Films

I bet you've got a few favourite films. So make a website about them! You will need:

  • A front-place explaining that this is your film website, with links to web-pages about each film.
  • A web-page for each film. The page should contain (at least) the film's title, image and a short summary of what it's about. You could also review and rate the film. It is a 4-star or 5-star film?
  • You could also have web-pages about actors and actresses in these films.
  • Be careful with the pictures you use on your website: you may need permission to use some pictures you link to. Wikipedia has film images with 'fair use' permissions. For example, the Frozen wikipedia page has a image in the top right. Clicking on it shows a bigger image, with a "Share or embed this file" option in the bottom right. The 'embed' option has HTML that will show the image in a webpage.

Challenge: Bob the Builder

Make a website for Bob the Builder.

"I'm Bob the Builder. I build houses: houses for people, dog-houses, dolls-houses, tree-houses.. If it's a house, I can build it. I want a website so people can find me on the Internet, see what I do, and contact me if they're interested. Hopefully I'll get some new customers! I reckon the website needs:

  • A home page, all about me (Boy the Builder), and what I do (building houses).
  • A page showing previous houses I've built. For each house, it should explain what was done, and have a nice quote from the customer about what a good job I did!
  • A "contact us" page, with the address and map of my builder's yard. The yard is actually at the Wallace Monument! The address is: Abbey Craig, Hillfoots Rd, Stirling FK9 5LF
I'm looking forward to what you come up with :-) Thanks, Bob"

Coding (in Python or Javascript)

Before you start

If you’ve never coded in Javascript or Python before, do our coding badges to get started.

If you have coded in Javascript or Python before, pick a challenge below and do it!

Here are two online environments where you can start coding immediately (or use whatever setup you want):

Challenge: Reversing Names

Write a program that asks someone their name, then outputs it in reverse. So “GREG” becomes “GERG”.

Challenge: Capital Cities

Write a program that asks for a country name, then outputs the capital city. So “France” returns “Paris”.

Getting started:

  • Start off with just 3 known country/capital combinations: get the information from wikipedia.
  • You’ll need to handle an unknown country being entered: just return “unknown country”.

More advanced:

  • Expand to lots of countries. Considering using the ‘hash table’ data structure.
  • Can your program handle “ fRanCE “, and still return “Paris”?
  • Can your program do the reverse, so “Paris” returns “France”?

Challenge: Rock Paper Scissors

Write a program that plays ‘rock paper scissors’:

  • Ask the player to pick ‘rock’, ‘paper’ or ‘scissors’
  • Have the computer choose its move (get it to make a random choice)
  • Compare the choices and decide who wins
  • Print the results

More advanced:

  • Let the player play again.
  • Keep a record of the score e.g. (Player: 3 / Computer: 6)

Challenge: Hangman

Write a program that plays ‘hangman’. The player guesses letters to complete a secret word. You decide how many turns they get. On each turn:

  • The player guesses a letter
  • The computer prints out the word, but shows ‘@‘ for letters not guessed yet. So if the word was ‘dog’ and the player had only guessed ‘d’, the computer would show: ‘d@@’
  • If the player has guessed all letters in the word, it prints the whole word and ‘you won!’
  • If the player hasn’t won, the computer prints ‘number of turns remaining: ___’, and the player has another go.

Challenge: Sentence Analyser

Write a program that counts the number of words in a sentence. For example, for “i am an example sentence”, the program would print 5 (words).

Then improve your sentence analyser:

  • Print out the total number of vowels in the sentence. So we’d print 9 for the example.
  • Print out counts for each vowel. For the example sentence, there is 1 ‘i’ and 3 ‘a’s and 5 ‘e’s.
  • Make sure your program works for lowercase and uppercase letters. So ‘A’ and ‘a’ should be treated the same. The phrase ‘A cat’ has two vowels, which are both the letter ‘a’.

Challenge: Calculator

Write a calculator that can add, subtract, multiply or divide two numbers. Make the calculator accept the two numbers and command one line at a time. Like:

  • 2
  • +
  • 3
  • And then the calculator outputs 5

More advanced: make the calculator accept everything on one line, like: 2 + 3.

Challenge: Fizz Buzz

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print “FizzBuzz".

Challenge: Fibonacci

Write a program that prints out the first 100 numbers in the Fibonacci sequence. In the Fibonacci sequence the first two numbers are zero and one. Every number after that is the sum of the previous 2 numbers. So the first seven numbers are: 0 1 1 2 3 5 8.

Challenge: Secret Spy Messages

Write a program that turns a sentence into a secret message by replacing each letter with the next letter. So the letter ‘a’ is replaced by ‘b’, and ‘f’ by ‘g’, etc. Here’s an example:

  • Original sentence: ‘attack at dawn’
  • Secret message: ‘buubdl bu ebxo’

Hint: letters are represented inside a computer as numbers. This is called ASCII: so an ‘a’ in ASCII is 97. You’ll need to convert the sentence letters into ASCII, do some addition, then convert them back again. Google to learn about ASCII, and how you convert letters to ASCII (and back again) in your particular programming language.

More advanced: so you’ve written a program that ‘encrypts’ a sentence into a secret message. Write a ‘decrypt’ program that turns a secret message back into the original sentence.

Challenge: Anagram Detector

Write a program that outputs whether two phrases are anagrams of one another. For example:

  • "Clint Eastwood" is an anagram of "Old West Action"
  • "parliament" is NOT an anagram of "partial man"

Getting started:

  • Start off with a program which asks for two phrases, then outputs the result like above
  • Here are some examples to test your program with:
    Anagrams:
    • "wisdom" and "mid sow"
    • "Seth Rogan" and "Gathers No"
    • "Schoolmaster" and "The classroom"
    • "Vacation Times" and "I'm Not as Active"
    Not anagrams:
    • "Reddit" and "Eat Dirt"
    • "Astronomers" and "Moon starer"
    • "Dormitory" and "Dirty Rooms"
  • Thanks to Reddit dailyprogrammer

Challenge: Reverse Factorial

Write a program that outputs whether a given number is a factorial (or not).

A factorial of a particular number is that number multiplied by all numbers below it. So 5! (meaning 5 factorial) = 5 * 4 * 3 * 2 * 1 = 120.

Calculating 5! is easy. But we want to reverse this. Write a program that tells us that "120" is "5!". The program should work for any number, either reporting that that the number is a factorial, or "NONE" if it isn't. For example:

  • 120 = 5!
  • 150 NONE

Getting started:

  • Hint: divide the input number by successively larger numbers until you get to "1" as the result: 120 -> 120/2 -> 60/3 -> 20/4 -> 5/5 -> 1 => 5!
  • Here are some examples to test your program with:
    Challenge input:
    • 3628800
    • 479001600
    • 6
    • 18
    Challenge output anagrams:
    • 3628800 = 10!
    • 479001600 = 12!
    • 6 = 3!
    • 18 NONE
  • Thanks to Reddit dailyprogrammer

Challenge: To-do list

Write a program that lets you create and manage a 'to-do list'. You should be able to: add an item, delete an item, and view the whole list (of items). Here's my example to-do list:

  1. Assemble an army of dolphins that will do as I command
  2. Use dolphin army to achieve world domination
  3. Eat chocolate chip ice cream with sprinkles on top

Getting started:

  • When the program starts, it should ask the user what to do: the user enters an alphabet letter to select an option. So it could be 'a' for add, 'd' for delete, and 'l' for list, and 'e' for exit program.
  • Code 'add an item': the user should enter the item to add (e.g. 'Eat chocolate chip ice cream with sprinkles on top').
  • Code 'view list': show all the items the user has entered.
  • Code 'delete an item': the user should enter the list item to delete (numbering list items will make it easier to select one)

Challenge: Reaction Time

Write a game that measures your reaction time: how fast you hit the space-bar when told 'hit it!'. At the end of the game, show your reaction time in milliseconds (a second divided into 1000 parts). What's your fastest reaction time?

Getting started:

  • When the program starts, show instructions explaining the game, and get the user to hit space-bar when they're ready to begin.
  • Wait say 5 seconds, then output "Hit it!" and start a timer.
  • When the user hits the spacebar, stop the timer.
  • Output the timer result (the reaction time).

More advanced:

  • Make the player pay attention: randomise the time at the game start before outputting "Hit it!"
  • Tell the player off if they hit the space-bar too early (before "Hit it!").
  • Let the player have multiple goes, and calculate their average reaction time.
  • Make the game more interesting by getting the user to enter a random letter between 'A' and 'Z', rather than the space-bar.

Challenge: Insult Generator

Make a program that generates random insults :-) The program first asks for your name, then insults you. Here goes..

  • "What's your name?"
  • "Greg"
  • "Hi Greg. You eat like a greasy baboon!". Or maybe "Hi Greg. You run like a purple hippo!"

Getting started:

  • When the program starts, ask the user for their name, then say hello ("Hi Greg").
  • Generating the insult is the tricky bit. Each insult is a sentence with the same structure: "Hi (Greg - name). You (eat - verb) like a (greasy - adjective) (baboon - noun). So we'll generate the insult by randomly picking a verb, adjective and noun, then making a sentence out of them:
    • Make a list of verbs. How about: eat, run and swim.
    • Make a list of adjectives. How about: greasy, smelly, grumpy.
    • Make a list of nouns. How about: baboon, cardboard box, dolphin.
    • Now we'll generate the insult by randomly picking a word from each of the three lists, and combining them into a sentence.
    • Go make some fun insults!

More advanced:

  • Make the insults more complicated and longer. Use bigger lists of verbs, adjectives and nouns.
  • Why stop with random sentence generation - try random story generation! Use the same approach, but your lists are now of whole sentences rather than single words. So define the story's standard structure, then randomly fill in story gaps with randomly picked sentences:
    • I was born (in Paris, under an autumn sky | with a tail | 3 days early).
    • My mother (ate chips all day | loved to dance | howled at the moon).
    • All I could do was (vacuum the cat | take up break dancing | cook bacon and eggs).

Coding - Microbits

At Stirling CoderDojo, we have micro:bits to play with. Ask a mentor if you would like to use one. A micro:bit is a cool little computer with LEDs, a compass, motion detection and temperature detection. So you can make it to do cool stuff like show the temperature when you shake it! There’s a web-based Block Editor (like Scratch) for writing and testing code. When you’re happy with the code, you need to transfer the code to the micro:bit. To do this:

  • Plug the micro:bit into your computer using the usb cable. The micro:bit should show up in your computer as a new hard drive
  • Click ‘compile’ in the Block Editor, and your code will download to your computer in a file called ‘something.hex’
  • Drag and drop the ‘something.hex’ file onto the micro:bit hard drive. The code should now be running on the micro:bit!
Useful links: