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: Santa Present Drop

Website: Make Stories with Twine

Coding: Twelve Days of Christmas


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.

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:

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

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: