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!"

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)

Making Websites

Before you start

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

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

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.

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 differentcolours.
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?

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

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!

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:

Assemble an army of dolphins that will do as I command

Use dolphin army to achieve world domination

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:

Advanced version

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:

reduce journey times by about 15%

increase fuel consumption by about 15%

reduce fuel consumption by about 15% (correct answer)

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?

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?

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.

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

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!