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 challenges:

Scratch: Rudolf hunts for his red nose

Websites: Your Christmas present wish list

Coding: Santa's Christmas list

Microbits: Talk between Microbits

And...


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!

Challenge: To the Moon

Write a game about flying to the moon. There should be three stages in your game: one set on Earth; one in space and one on the moon.

To start the rocket the player should press the space bar five times. Then the rocket should fly into the air. When the rocket reaches the top of the screen, the background should be changed to the next background (e.g. from Earth to space). Along with placing the rocket at the bottom of the screen again. The player should be able to move the rocket left and right using the arrow keys. There should be Aliens and other space-ships flying around. If the player touches one of these they lose the game. When the player reaches the last stage (the moon) a target should appear. The target should be placed at the top of the screen. If the player hits the target then they win the game.

Hints

  • For a spaceship sprite look in the sprite library (they'll be found in flying).

  • To count the number of times the player has pressed space make a variable (found under data). Then every time space is pressed add one to this variable. Use the wait until block to make the sure the rocket doesn't fly off until the variable equals five. Ask a mentor for help if you haven't used variables before.

  • To change the background check whether the y coordinate is bigger than 180, then use the switch background block.

Advance

If you manage to complete the above try and place the target at the bottom of the screen. Then have the rocket start at the top and move down the screen (towards the target).

Balloons

Write a small game about popping balloons. In the game the balloons should float from the bottom to the top of the screen. When the player clicks on a balloon then it should disappear from the screen, and a popping sound should be played. Then one should be added to their score. There should be other items floating up the screen; if the player clicks on any of these they should lose a point.

Advanced

  • If the player's score falls below zero then a game over screen should appear.
  • Add a lives system to the game. If the player clicks on something that isn't a balloon then they lose a life. When the player runs out lives they lose the game.

Back to School Supplies

So you're going back to school - you'll need to make sure you've got a pencil, notebook and calculator.

Fortunately, it's raining school supplies. Your sprite needs to walk back and forth across the screen catching pencils, notebooks and calculators in their backpack. Set up a timer so that players have one minute to collect as many as they can. Set up a counter to count how many items they catch.

Hints:

  • Draw a sprite of you in school uniform, with a backpack. You will need two costumes: one for when you are walking left, and another for walking right.
  • Draw a pencil, notebook and calculator sprite. To make them fall from the sky, set their original location to a random position at the top of the screen, then move their location down the screen. When they get to the bottom, move them back to the top.
  • An easy way to 'catch' a notebook (or whatever) in your backpack is to make the backpack a special color, then add an action to the notebook sprite when it touches the special color. So you could hide the notebook, and add a point to the score.

Advanced

  • Add a second level with extra supplies. If any supplies hit the ground, they explode!
  • Add something that you should not take to school. If the player catches that item accidentally, a message flashes up "You're in Detention!"

Frogger

Make your own version of a classic 1980s game called "Frogger". Check out this video. The aim of the game is to guide a frog from the bottom of the screen to the top of the screen, whilst crossing lanes of a busy road. Each lane contains moving cars, buses, cyclists and other vehicles - don't let the frog get run over! The player moves the frog using the arrow keys (hopping forwards, back, left or right). The player wins by guiding the frog safely to the top of the screen.

Hints:

  • You'll need a frog sprite. Make it "hop" up, down, left and right using the arrow keys.
  • You'll need some vehicle sprites. Move them left to right (or right to left) along a road. You can draw roads in the background image. To have constant traffic, start each sprite on the the left of the screen, then move it right. When the sprite gets to the right of the screen, move its location back to the left.
  • You can detect collisions between the frog and a vehice based on colour (when touching "frog" colour) or sprite (when touching "frog" sprite).

Advanced

  • Add scoring: 10 points every time the frog moves forward, and 50 points when the frog crosses all roads successfully.
  • Add a time limit: frog must cross in under 30 seconds.
  • Add multiple frogs: the player has to guide 5 frogs across the roads, one at a time.

Halloween Night

Create a Halloween scene: for example a spooky forest or a graveyard. When you click on anything in the scene, something scary should happen. A spider drops from this tree; an owl flies out of that one; a ghost pops out from behind a gravestone; a witch flies cackling across the moon. How many spooky surprises can you put in?

Hints:

  • You'll need sprites. Look in the sprite library, or draw one, or load one in from an image.
  • For surprises, a sprite could move or appear, say something, or make a sound. You could even record your best ghost noise!

Santa Present Drop

Santa needs help dropping presents down chimneys. Make a game where Santa flies across the sky over some houses with chimneys. When the mouse is clicked, Santa drops a present which falls downwards. If the present hits a chimney, you score 1 point. If the present hits something else (like a roof), you score nothing. In either case, the present vanishes, and you get to try again. You win once you've scored 10 points.

Hints:

  • You'll need a Santa sprite. Make him fly across the top of the screen. When Santa hits the edge of the screen, make him fly in the opposite direction.
  • You'll need a sprite of some houses with chimneys. Use two different colours for the chimney tops and the rest of the houses.
  • You'll need a present sprite. When the mouse is pressed, make the present appear at Santa's location. Then move its position gradually down the screen. You can work out if the present lands on a chimney. top by using "if touching chimney top colour". You can check if the present lands on a house instead by using "if touching house colour".
  • You'll need a variable to keep track of the score. Add 1 to the score when a present drops on a chimney top.

Advanced

  • Add fun sounds: Santa saying "ho ho ho", a "yay!" noise when a present hits a chimney, and "boo hoo!" when it doesn't
  • Add levels: once you score 10 points, move up one level. Santa should fly faster as each level increases. You will need a second "level" variable for this.

Avoid Cake

Scratch Cat has made a New Year Resolution not to eat cake. Write a game where Scratch Cat has to dodge cakes that fly round the screen. If Scratch Cat touches cake, he loses a life (and the cake vanishes - yum yum!). Scratch Cat has 9 lives. When he runs out of lives, the game finishes. The player should then be told how many seconds Scratch Cat survived.

Hints:

  • Make Scratch Cat move left, right, up or down when the player presses the matching arrow key.
  • You will need some cake sprites. To make them bounce around the screen, you can use the "if on edge, bounce" block, in the "Motion" section.
  • You will need a "variable" to count the number of lives remaining. Look in the "Data" section.
  • You will need a "timer" to count how long Scratch Cat survived. Look for the "timer" block in the "Sensing" section.

Advanced

  • Make the game harder: make the cake move towards Scratch Cat, add more cake, and make the cake move faster.
  • Add difficulty levels: let the player choose at game start how hard they want the game to be. Then set cake speed based on difficulty.

Robot Disco

Make a scene of a robot disco! There are two robots dancing, waving their arms and their legs. There should be crazy electronic music playing, and some flashing lights. Make it a cool robot disco.

Hints:

  • Make a robot by creating a new sprite, and drawing its costume out of shapes like squares and circles. Make sure the robot has arms and legs!
  • To make the robot dance, you will need to make a second costume that looks the same as the first, but has arms and legs in slightly different positions (you will then flip between the costumes very quickly, so it looks like the robot is dancing). To make a second costume, right click on the first costume and select 'duplicate'. Now you can move the arms and legs in the second costume.
  • Flip between the costumes using the 'next costume' block inside a 'forever' block. You will also need a 'wait n seconds' block to change how fast the costumes change.

Advanced

  • Make the robot dance more smoothly by adding more costumes. So only move the robot's arms and legs a little bit in each costume.
  • Make the robot disco as cool as possible. Can the robots move? Can you add more robots? Can you record your own (beat boxed) soundtrack?

Easter Egg Hunt

Make an easter egg hunt game - you win by finding 10 easter eggs hidden behind things in a country scene. When you click on a hidden egg, it becomes totally visible for 2 seconds, then vanishes.

Hints:

  • You will need 10 easter egg sprites and some things for them to hide behind like a tree, a rock, a house, and maybe an easter bunny! You can draw the sprites, or use ones from the Scratch sprites library.
  • To hide an egg, first place the egg so it would just peek out from behind an object (like a rock), if the rock was in front. Take a note of the egg's location (as x and y coordinates).
  • To hide the egg behind the rock, give the egg the following commands when the game starts (the green flag is clicked): "Go to x, y" (under Motion) and "go back 1 layers" (under Looks). So you're placing the egg by the rock, then hiding it behind the rock (the rock is in the top layer, the egg is one layer behind).
  • When someone clicks on the egg, you can make it appear fully with the "go to front" command (under Looks). You will also need to hide the egg after 2 seconds, and increase the game score by 1 (use a "variable").

Advanced

  • Keep track of how long it takes for someone to finish the game. When the game ends, tell them how long they took.
  • Add some hidden eggs at random locations. So the player will need to randomly click round the screen to find them!

April Showers

It rains a lot in April. Make a game where you dodge raindrops. Get hit by 3 raindrops, and the game finishes. The player should be told how many seconds they survived.

Hints:

  • You will need a player sprite to move left and right at the bottom of the screen, to dodge the raindrops. Draw a sprite yourself, or pick one from the scratch library. Then make it move left and right when the arrow keys are pressed
  • You will need raindrops to fall from the sky. Draw one raindrop. When the game starts, hide this raindrop, then "clone" it every half a second (look in the "control" section). Use the "when i start as a clone" block to tell each cloned raindrop what to do (also in the "control" section). Each clone should:
    • Appear using "show"
    • Start at a random location at the top of the screen. Use a y position of 180, and a random x position between 240 and -240
    • Move down the screen
    • Delete itself at the bottom using the "delete this clone" block
  • You can check if the player has hit a raindrop using the "touching sprite" block in the "sensing" section
  • You will need a variable to keep track of how many hits the player has taken. When the player touches a raindrop, subtract 1 from the variable. When the variable gets to zero, the game finishes
  • You can measure how long the player survived using the 'timer' block in the 'sensing' section. Use 'reset timer' to start timing, and assign 'timer' to a variable to stop timing (when the game finishes)

YouTube tutorial: make a zombie survival game

There are some good video tutorials on YouTube that show you how to make cool things with Scratch. Follow along with this 10 minute video tutorial, where you learn how to make a zombie survival game: the player is attacked by zombies, and can run around and shoot the zombies.

Once you have your own zombie game working, then you can improve it how you want, or keep watching more video tutorials in the series. There are 9 more videos: part 2, part 3, part 4, part 5, part 6, part 7, part 8, part 9 and part 10.

There are plenty more video tutorials on YouTube about making games in scratch: try searching for "Make a scratch game". For example, here is a video playlist that shows how to make a 'cat chasing mouse' game, a 'whack a mole' game, and more.

Virtual pet: beach holiday

Scratch Cat has gone on holiday to the beach. He will need regular food, drink and sunscreen to enjoy himself. If he doesn't get enough of each then he'll be hungry, thirsty and sunburnt. Scratch Cat will then come home from holiday early as he feels unwell. Sadness.

Make a "virtual pet" game where you keep Scratch Cat on his beach holiday for as long as possible. You will need to give him food, drink or sunscreen, depending on what he needs. The basic idea is that you have "variables" that show how Scratch Cat is feeling, like: "Hungry: 4". Scratch Cat gets hungrier over time, so the variable starts at zero and increases 2 points every 5 seconds. The player can reduce points by feeding Scratch Cat: they do this by clicking on some cat food. If the "Hungry" variable gets to 20 points, then Scratch Cat feels unwell and goes home early: the game finishes. You will need three different variables: "Hungry" (fixed by cat food), "Thirsty" (fixed by a water bowl), and "Sunburnt" (fixed by sunscreen).

To get started, let's deal with Scratch Cat being hungry:

  • Add the Scratch Cat sprite and a beach background
  • Add a variable called "Hungry", and set it to zero when the game starts. Then make the variable increase 2 points every 5 seconds.
  • Add a "cat food" sprite. Reduce the "Hungry" variable by two points when the player clicks on the cat food.
  • Check to see if the "Hungry" variable is 20 points or more. If it is, then stop the game: make Scratch Cat say that he's going home.

Next steps:

  • Add "Thirsty" and "Sunburnt" variables, fixed by a water bowl and sunscreen
  • Increase the variables randomly, so "Hungry" increases between 2 to 4 points, every 5 to 10 seconds
  • When the game finishes, tell the player how long Scratch Cat was on his beach holiday.

YouTube tutorial: make a RPG/Adventure Game

Learn how to make an adventure/RPG (role-playing game) game by following along with this 10 minute video tutorial.

Once you have your own game working then you can improve it how you want, or keep watching more video tutorials in the series. There are 5 more videos: part 2, part 3, part 4, part 5 and part 6.

Spy Name Generator

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

  • "What's your name?"
  • "Greg"
  • "Hi Greg. Your spy name is Smelly Weasel". Or maybe "Hi Greg. Your spy name is Pink Milkshake"

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 spy name is the tricky bit. Each spy name is a sentence with the same structure: "Hi (Greg - name). Your spy name is (Smelly - describing word) (Weasel - noun)". So we'll generate the spy name by randomly picking a describing word and a naming word, then making a sentence out of them:
    • Make a list of describing words (adjectives). Use 'Make a list' under 'Data'. How about: Smelly, Pink and Furry.
    • Make a list of naming words (nouns). How about: Weasel, Milkshake, Goblin.
    • Now we'll generate the spy name by randomly picking a word from each list, 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 spy names!

To finish things off, let's replace Scratch cat with M: head of the Secret Service in James Bond films. Make a new sprite for M: they should be dressed in normal clothes. Now add an extra "spy" costume for M: they should be dressed like a spy, with dark glasses, a fake moustache, and maybe all in black. When M asks your name, show them in their normal costume. But when M tells you your spy name, show them in their spy costume. Cooool.

Going to School

Make a story about you going to school. There will be 3 screens (each using a different backdrop):

  • First, your bedroom. Your Mum comes in and says "wake up!"
  • Second, on the way to school. You meet a friend and say hi to one another
  • Third, at school. Make something interesting happen, like being attacked by a giant octopus, or have a witch flying overhead
Getting started:
  • Scratch has different sprites and backdrops you can choose from, or you can create your own. For backdrops look bottom left for "Choose backdrop from library"
  • You can switch between backdrops using "switch backdrop" in the "looks" section.
  • So you and your Mum have a conversation in the bedroom: Mum says "wake up!", then you say "ok!". Your two sprites have to take turns saying something. Use the "broadcast" and "when I receive" blocks in the "events" section to make this happen. Watch this 4 minute video showing how it's done

YouTube tutorial: make a shoot ’em up game with planes

Learn how to make a shoot’em up game by following along with this 10 minute video tutorial. Your aeroplane is being attacked by a swarm of enemy planes!

Once you have your own game working then you can improve it how you want, or keep watching more video tutorials in the series. There are 3 more videos: part 2, part 3, and part 4.

Rudolf hunts for his red nose

Rudolf woke up on Christmas morning and couldn't find his red nose. Make a reindeer sprite either from a picture or by drawing in Scratch. Draw a complicated maze sprite and hide a sprite of Rudolf's nose somewhere in it. Make Rudolf move with keys on the keyboard. He should bounce off the walls of the maze. When he finds his nose, change sprite costumes so that his nose disappears from the maze and appears on Rudolf.

Getting started:

  • You will need three sprites; one for Rudolf, one for his nose and one for the maze
  • Some sprites will need multiple costumes
  • To make something disappear you can change costume or you can use the show and hide blocks

More advanced: Animate a celebration after Rudolf finds his nose with fireworks and dancing.

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"

Challenge: my favourite game

My favourite game. Write a small website about your favourite game(s). The website should contains:

  • A short of description of the game. What's about it? What are the goals of the game? How long does it take to complete? Is there a story? Who's it developed by? And any other relevant.

  • A link to the game site

  • Images and videos of gameplay

Advanced

Pick a browser game you like and write a new page for it with all the details specified above. Though also try and place the game in page. Hint: Lookup what an iFrame is

What I did on my summer holiday

Write a website about your summer holiday. The site should have a page for each activity you have done. Every page should have a brief description of what you did, who you were with and where you were. Along with some pictures of the place. Every page should link to the others.

Rate my teacher

Write a website about the teachers in your school. Each teacher should have their own page, describing what they teach, how much homework they give, how strict they are, what their classroom is like, etc. You could add a drawing of each teacher to help new pupils identify them. Don't forget the Head Teacher! You could arrange the front page so that the teachers are organised by subject.

Best Memes Ever

Make a website with the best memes ever. It should be possible to view memes by animal type, subject and year, so you'll need different web pages for this.

Fun with Fonts

How text appears on a webpage depends on which font is used. For example, we could use the Courier font, or Verdana font. Write a webpage that shows the same piece of text with different fonts: use the sentence "the quick brown fox jumped over the lazy dog". The text will feel different, depending on the font used. Try finding fonts that look official, funny, old or futuristic. What's your favourite?

Getting started:

  • Work out how to use CSS to use a particular font for a piece of text. Try using the fonts that are built into your web browser.
  • You can find lots more fonts at Google Fonts. They also have a nice Getting Started guide.

Make Stories With Twine

Twine is an online tool for telling interactive stories. Here are two examples:

Make your own story using Twine. It's easy to use once you get the hang of it. Here are some useful guides:

Twine Story: A Day in the Life of Timmy the Dog

Make a "Choose Your Own Adventure" story with Twine called "A Day in the Life of Timmy the Dog".

If you don't know how to use Twine to make stories, then do the "Make Stories with Twine" challenge first.

To start you off, your first page might look like:

                        Timmy the Dog is sniffing the rubbish bin outside his house. Suddenly he hears a rustle behind him, and
                        sees Sooty the Cat staring. Timmy:

                        * Walks up to Sooty, and tries to make friends.
                        * Bounces up to Sooty, and starts a fight. That cat needs a lesson.
                        * Runs awwaaaaay! Sooty is scary.
                    
Each choice is a link to another page, where the story continues. So what happens when Timmy runs away, or starts a fight?

CSS Selectors Game

Complete the CSS Selector Game, to learn about CSS selectors. It's got 32 levels, so should take some time!

If you're not clear on what a CSS selector is, you might want to do one of these courses first:

Easter Traditions

Make a website about different Easter traditions around the world - a page for each one. For example, eggs are rolled down hills in the United Kingdom, whilst Spain holds processions to celebrate Semana Santa (Holy Week). Use pins on Google Maps to show where each tradition happens.

Colour Codes

CSS lets you write text and backgrounds in different colours. Write a webpage that shows the same piece of text with different background and text colours: use the sentence "the quick brown fox jumped over the lazy dog". Use a large font size so you can get a good look at the colours. Choose colour combinations that are readable. Which combinations don't work together, and why? What's your favourite?

Welcome to Paris

It's the summer holidays. Are you going somewhere nice? Paris? Ooh la la!

Imagine you're the Paris Tourist Board (or any other holiday destination). Make a website for tourists visiting Paris. You will need:

  • A front page saying "Welcome to Paris", with nice pictures, and links to other pages covering...
  • Things to do in Paris, listing tourist attractions
  • Where to stay in Paris, listing hotels
  • How get to Paris, explaining flights and trains
  • And any other webpages that might be useful to a tourist

Introduction to Scratch

Make a website telling people about Scratch: what it is, and what you can do with it.

You can link to Scratch games and stories you like. If you've made some Scratch games and stories yourself, then link to them as well, and write down what was interesting or challenging about making them.

Show off your Scratch knowledge!

Codecademy course: Learn Javascript

Javascript is the coding language used to make websites interactive and whizzy. Take a look at the free Codecademy "Introduction to Javascript" course.

Your Christmas present wish list

Create a website for your Christmas present wish list. Lay all the details out neatly in a table. You could have a column for the presents, another column for where to buy them from and another for options like colour . Give your website a nice big title. Add a bit of sparkle with an animated background made from images you find about Christmas.

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).

Triangles

Write a small program that takes in a number and then prints off a triangle of that height. Here is an example:

                  Please enter the height of the triangle:
                  5

                  Output:
                           #
                         ##
                       ###
                     ####
                   #####
                

The program should only accept whole numbers between 3 and 10.


Advanced version

Once you've finished the basic version, try and produce the following output:

                    Please enter the height of the triangle:
                    5

                    Output:
                              ##
                            ####
                          ######
                        ########
                      ##########


                  

Greedy shopkeeper

Write a small program that takes an amount of change, and then works out the minimal coins required to make it. You may only use the: 50, 20, 10, 5, 2, and 1 pence coins.

Example

                  Input:
                    0.73

                  Output:
                    1 x 50
                    1 x 20
                    1 x 2
                    1 x 1
                

The program should only accept positive numbers and the input must never be bigger or equal to one.

Advanced

  • When formatting the output avoid using string concatenation (i.e. "str1, " + "str2" becomes "str1, str2"), instead look up how to use .format() in python or `` (the grave accent) in JS.
  • Let the program accept inputs bigger than one. Now you may use the one and two pound coins. As well as the previous coins.

School timetable manager

So you're going back to school. Write a program that manages your school timetable. It should record which subjects you take during your school day. E.g.:

  • MON-PERIOD1: CHEMISTRY
  • MON-PERIOD2: ENGLISH
  • MON-PERIOD3: MATHS
  • MON-PERIOD4: ART
  • MON-PERIOD5: GEOGRAPHY
  • MON-PERIOD6: PE
You can then ask the program what subject you have for a particular day+hour.

Example

                  Input:
                    MON-PERIOD2

                  Output:
                    ENGLISH
                

Advanced

  • Make the program print the entire week timetable, nicely formatted.
  • For a given subject, make the program print out every period in the week when you take that subject.

Driving Theory Test

Getting your driving licence requires you to pass a "theory test". Write a program that lets you practice the theory test: the program asks you a set of multiple-choice questions, tells you whether you correctly answered each question, and tells you your final score at the end. Here's an example question:

You will find that driving smoothly can:

  1. reduce journey times by about 15%
  2. increase fuel consumption by about 15%
  3. reduce fuel consumption by about 15% (correct answer)
  4. increase journey times by about 15%
When presented with this question, the user types in the number of the answer they think is correct (e.g. 1 - incorrect). The program then states whether the user is correct or not, and moves onto the next question.

Hints

  • You'll need to find some practice questions. The UK government website has some.

Advanced

  • Time how long someone took to complete the test, and tell them on test completion.
  • Write another program that asks multiple-choice questions for a different topic. Try and share as much code as possible between the two programs.

Speaking Clock

Write a program that takes a time in 24 hour numeric form, and outputs it as words.

Challenge input:

  • 00:00
  • 01:30
  • 12:05
  • 14:01
  • 20:29
  • 21:00
Challenge output:
  • It's twelve am
  • It's one thirty am
  • It's twelve oh five pm
  • It's two oh one pm
  • It's eight twenty nine pm
  • It's nine pm

Advanced

Can you make the computer actually speak the time as words, so you have a real speaking clock?

Thanks to Reddit dailyprogrammer

Twelve Days of Christmas

Write the smallest possible program to print all the lyrics to the "Twelve Days of Christmas":

                On the first day of Christmas my true love sent to me:
                a Partridge in a Pear Tree

                On the second day of Christmas my true love sent to me:
                two Turtle Doves
                and a Partridge in a Pear Tree

                On the third day of Christmas my true love sent to me:
                three French Hens
                ...
                

Hints

To start with, get things working by using numbers (rather than words) for the gift counts:

                On the second day of Christmas my true love sent to me:
                2 Turtle Doves
                and 1 Partridge in a Pear Tree
                

Advanced

  • Load all the gifts ("Turtle Doves", "Partridge in a Pear Tree", ..) from an input file, so you can change them easily.
  • Can you get the computer to play the melody of Twelve Days Of Christmas as well?

Thanks to Reddit dailyprogrammer

How Long Was The Light On?

There is a light that switches on when someone enters the room, and switches off when they leave. If multiple people are in the room, the light stays on until the last person leaves. Write a program that outputs how long the light stays on, given a list of when people entered and left the room.

Challenge input:

  • 1 3 (so person arrived at 1 o'clock, and left at 3 o'clock)
  • 2 3
  • 4 5
Challenge output:
  • 3

More input and output:

                Input:
                2 4
                3 6
                1 3
                6 8

                Output: 7
                
                Input:
                6 8
                5 8
                8 9
                5 7
                4 7

                Output: 5
                

Advanced

Can you change the program to work with more precise times? E.g 09:00 09:25.

Thanks to Reddit dailyprogrammer

L33T SPEAK

Write a program that translates English into Leet Speak (or vice versa). Examples:

  • BASIC => 6451C
  • ELEET => 31337 (pronounced elite)
  • WOW => `//0`//
  • MOM => (V)0(V)
Use the following l33t:
                        A -> 4
                        B -> 6
                        E -> 3
                        I -> 1
                        L -> 1
                        M -> (V)
                        N -> (\)
                        O -> 0
                        S -> 5
                        T -> 7
                        V -> \/
                        W -> `//
                    
The program takes in one word or phrase per line, and converts it to (or from) l33t:
  • 31337 -> eleet
  • storm -> 570R(V)

Challenge input:

                I am elite.
                Da pain!
                Eye need help!
                3Y3 (\)33d j00 t0 g37 d4 d0c70r.
                1 n33d m4 p1llz!
                
Challenge output:
                I am elite. -> 1 4m 37173
                Da pain! -> D4 P41(\)!
                Eye need help! -> 3Y3 (\)33D H31P!
                3Y3 (\)33d j00 t0 g37 d4 d0c70r. -> Eye need j00 to get da doctor.
                1 n33d m4 p1llz! -> I need ma pillz!
                

Thanks to Reddit dailyprogrammer

Noughts and Crosses

Code the game of 'Noughts and Crosses':

  • Write a 2 player version first, with each player entering their move one after the other. Use ASCII art to show the state of the board, with board locations specified as in chess (like b3).
  • Write a one player version next, so you will need to write a basic arificial intelligence :-)

Example

                    a   b   c
                  |---|---|---|
                1 |   |   |   |
                  |---|---|---|
                2 |   |   |   |
                  |---|---|---|
                3 |   | X |   |
                  |---|---|---|

                  Player one, you are noughts. Enter your move: b2

                    a   b   c
                  |---|---|---|
                1 |   |   |   |
                  |---|---|---|
                2 |   | O |   |
                  |---|---|---|
                3 |   | X |   |
                  |---|---|---|

                  Player two, you are crosses. Enter your move:
                

Seconds Convertor

Write a program that converts a number of seconds into years/months/weeks/days/hours/minutes/seconds. Assume that there are 365 days in a year, and 28 days in month.

Examples:

  • 1234567 => 14 days, 6 hours, 56 minutes, 7 seconds
  • 145252000 => 5 years, 1 day, 3 hours, 46 minutes, 40 seconds

Battleship

Write a 1-player version of the game 'Battleship'. Start with the simple version:

  • The game board is a 10 by 10 grid of squares, representing the sea.
  • When the game starts, 4 submarines are randomly placed on the board, on 4 different squares. None are visible to the player.
  • On the player's turn, they specify a board square they wish to "shoot". The board square is updated with their shot, and the player is told if they "HIT" or "MISSED" a submarine. For a "HIT", the square character is set to "x". For a "MISS", it is set to a "~"
  • The game finishes after 40 turns, or earlier if the player destroys all submarines.

Example

                    a   b   c   d   e   f   g   h   i   j
                  |---|---|---|---|---|---|---|---|---|---|
                1 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                2 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                3 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                4 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                5 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                6 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                7 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                8 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                9 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                10|   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|

                  Player, enter your move: d2

                    a   b   c   d   e   f   g   h   i   j
                  |---|---|---|---|---|---|---|---|---|---|
                1 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                2 |   |   |   | x |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                3 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                4 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                5 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                6 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                7 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                8 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                9 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                10|   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|

                  HIT!

                  Player, enter your move: a4

                    a   b   c   d   e   f   g   h   i   j
                  |---|---|---|---|---|---|---|---|---|---|
                1 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                2 |   |   |   | x |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                3 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                4 | ~ |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                5 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                6 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                7 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                8 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                9 |   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|
                10|   |   |   |   |   |   |   |   |   |   |
                  |---|---|---|---|---|---|---|---|---|---|

                  MISS :(

                  Player, enter your move: ..
                

The more advanced version of battleship has ships that are a line of squares, and are placed horizontally or vertically:

  • When the game starts, All ships are randomly placed on the board, either horizontally or vertically. Two ships cannot occupy the same square. The are 4 submarines of size 1 (already done), 3 destroyers of size 2, 2 cruisers of size 3, and one battleship of size 4.
  • On the player's turn, they again specify a board square they wish to "shoot". A ship can be hit as before (represented by "x"), but is only completely sunk when all the ship's squares are hit (represented by "*"). So the player is told if they "HIT", "MISSED", or "SUNK" a ship, and the board is updated.
  • The game finishes after 40 turns, or earlier if the player sinks all ships.

Calendar app

Make a calendar program. The user can:

  • Add events for a particular day
  • List all events for a particular year, month or day
  • Remove a particular event

Example

                What do you want to do?
                1. Add an event
                2. List events
                3. Delete an event

                => 1

                Please enter the day of the event:
                => 2018-06-29
                Please enter the event information:
                => Attend CoderDojo
                Event "Attend CoderDojo" added for 2018-06-29

                What do you want to do?
                1. Add an event
                2. List events
                3. Delete an event

                => 2

                Please enter the date range to list events from (e.g. year: "2018", or month "2018-06", or day "2018-06-29"
                => 2018-06
                Events in 2018-06:
                2018-06-29: "Attend CoderDojo"

                What do you want to do?
                1. Add an event
                2. List events
                3. Delete an event

                => 3

                Please enter the date range to list (deletable) events from (e.g. year: "2018", or month "2018-06", or day "2018-06-29"
                => 2018-06
                Deletable events in 2018-06:
                1. 2018-06-29: "Attend CoderDojo"
                Which event do you wish to delete? (enter its number)
                => 1
                Event deleted:
                2018-06-29: "Attend CoderDojo"
                

Regular Expressions

What if you need to find particular letter sequences in a large piece of text, like all email addresses, or all phone numbers? You'll need something called a "regular expression" for that. A regular expression lets you define the pattern of letters that you're looking for, and then find all letter sequences matching that pattern. For example, the regular expression "ab+a" says "match sequences of letters that start with 'a', are followed by any number of 'b's, and end with another 'a'. So this regular expression matches "aba", "abba", "abbba" and so on.

Learn about regular expressions by playing the RegexOne game. The game gradually teaches you more complicated regular expressions through a sequence of exercises. When you've finished this, you can play around with regular expressions at regex101.

Word Funnel

Write a program that takes two words, and says whether the second word can be made from the first by removing one letter. All other letters must remain in the same order. For example:

  • funnel("leave", "eave") => true
  • funnel("reset", "rest") => true
  • funnel("dragoon", "dragon") => true
  • funnel("eave", "leave") => false
  • funnel("sleet", "lets") => false
  • funnel("skiff", "ski") => false

Advanced

For every word in the dictionary, output all other words that can be made by removing one letter from the first (using what you just coded :-). For example:

  • bonus("coasts") => {'coast', 'costs', 'oasts', 'coats', 'casts'}
To get started, here's a link to a dictionary of words

Thanks to Reddit dailyprogrammer

Scoring a Game

5 friends (called Alex, Ben, Caitlin, Dean and Erin) are playing a game, and keeping track of scores. When someone scores a point, their initial (letter) is typed in lowercase. When they lose a point, their initial is typed in uppercase. So "aaAb" means in that round Alex (player "a") gained two points then lost a point, then Ben (player "b") gained a point. Write a program which takes in the recorded scores, and gives the total scores for each player, ranked high to low. So "aaaAb" would be: a:2, b:1.

Challenge input:

                abcde
                dbbaCEDbdAacCEAadcB
                EbAAdbBEaBaaBBdAccbeebaec
                
Challenge output:
                abcde -> a:1, b:1, c:1, d:1, e:1
                dbbaCEDbdAacCEAadcB -> b:2, d:2, a:1, c:0, e:-2
                

Thanks to Reddit dailyprogrammer

Convert currency with API data

Write a program that converts one currency amount to another. Here is an example of UK pounds (GBP) to US dollars (USD):

  • Input: 1.22 GBP to USD
  • Output: 1.57 USD
You will need currency conversion information: for each currency what is the rate to convert into other currencies? To start with, just allow conversions from UK pounds (GBP) to 3 other currencies, using these conversion rates:
  • GBP -> USD: 1.2793188994
  • GBP -> EUR: 1.1276499774
  • GBP -> JPY: 143.3581416328
Now to make it more fun, use an Internet API to get live currency conversion information. Use https://exchangeratesapi.io: You will need to call the API for currency information, load the response (which is in JSON format), read out the currency conversion rate you want, and use it.

Santa's Christmas list

Santa needs to write a list of all the good children and what they want for Christmas. Write a program in any language to ask for a name. Then ask if they have been good this year. If they have been good, store the name in a list called names and ask what present they would like. Store the present in another list called presents. The elves need to read the list to pack the presents. Show each name next to the present they want on the screen.

Getting started:

  • To ask a question in Python use an input() statement; in Javascript you can use prompt
  • Your lists can be a Python list, a Python dictionary, a Javascript array or many more

More advanced: The elves sometimes get confused and need to look up what present they packed for who. Ask for a name, find it in the names list and look up what present they had from the presents list. Print the name and present to the screen.

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:

Talk between Microbits

Find a friend and talk between Microbits. Use the radio functions on the microbits to get them to talk to each other.

Simple:

More complicated: