Invite
Search results
In level 5 there is something new, the if! With the if you can choose between two different options.
This code prints nice if you enter Hedy as a name, and boo! if you enter something else.
ask and print still work like they did in level 4.
name is ask 'what is your name?'
if name is Hedy print 'nice' else print 'boo!'
Sometimes code with an if gets really long and does not fit on the line well.
You may also divide the code over two lines, starting the second line at the else like this:
name is ask 'what is your name?'
if name is Hedy print 'nice'
else print 'boo!'
Try to create your own code with if and else. You can use the example code if you want.
answer is ask '2 + 2 = ?'
_ _ _ 4 _ 'Great job!'
_ _ 'No 2 + 2 = 4'
You don't always have to use the play command to play a whole song, sometimes you just want to play one note.
For example, if you want to make a quiz, you can play a happy high note if the answer is right and a sad low note if the answer is wrong.
Finish the first question by adding a line of code that plays a C3 note if the wrong answer is given. Then think of 3 more questions to add to this quiz.
answer is ask 'What is the capital of Zimbabwe?'
if answer is Harare play C6
_
Make your own program to practice your vocabulary in a new language.
Make the code longer by adding at least 3 more words for the player to learn. Extra Of course, you can choose to use a different language than French. You can change to code to any language you'd like to learn.
print 'Learn French!'
cat is ask '🐱'
if cat is chat print 'Terrific!'
else print 'No, cat is chat'
frog is ask '🐸'
if frog is grenouille print 'Super!'
else print 'No, frog is grenouille'
We are going to add the if and else commands to our dice!
Complete the sample code so that the code says "You can stop throwing" once you have thrown an earthworm. It should say "You have to throw again" if you've thrown anything else. Extra Maybe you want to recreate a die from a completely different game. That's fine too! Then make up your own reaction, e.g. 'yes' for 6 and 'pity' for something else.
choices is 1, 2, 3, 4, 5, earthworm
throw is choices at random
print 'you have thrown ' throw
_ throw is earthworm print 'You can stop throwing.'
_ print 'You have to throw it again!'
With the if you can now have more fun with choice in the program. You can have your program respond to the choice that the computer has made.
Can you finish the code so that it prints 'too bad' when it is your turn and otherwise 'yes!'? Don't forget the quotes!
people is mom, dad, Emma, Sophie
dishwasher is people at random
_ dishwasher is Sophie print _ too bad I have to do the dishes _
_ print 'luckily no dishes because ' _ ' is already washing up'
In this level you can program different endings, which will make your story even more fun. In the example code you can see how to make 2 different endings.
Write a new short story of at least 6 lines of code about a topic of your choosing. No inspiration? Choose one of these topics: a superhero, a boring school day, stranded on a desert island.
Now give the player a change to choose a happy or a bad end, just like in the example code. Program both the endings.
Copy the story you've created in your own story adventure in the previous levels.
Find a way to add at least 2 if and else commands to your story.
This can be with a happy or bad ending, but you can also try to find other ways to incorporate the commands.
name is ask 'Who is walking in the forest?'
print name ' walks through the forest'
print name ' encounters a monster'
end is ask 'Would you like a good or a bad ending?'
if end is good print name ' takes the sword and the monster quickly runs away'
else print 'The monster eats ' name
In this level we can determine whether it's a tie or not. For that you need the new if code.
Finish the code by filling in the blanks:
options is rock, paper, scissors
computer_choice is _
choice is _
print 'you chose ' _
print 'computer chose ' _
if _ is _ print 'tie!' else print 'no tie'
Fill in the correct code on the blanks to see if it is a draw.
Reward your parrot if it says the correct word!
Finish the code by filling in the 4 missing commands.
words is squawk, Hedy
print 'Train your parrot!'
new_word is ask 'Which word do you want to teach them?'
add new_word to words
said_word is words at random
print '🧒 Say ' new_word ', Hedy!'
print '🦜 ' said_word
_ said_word is new_word _ '🧒 Great job, Hedy! 🍪'
_ _ '🧒 No, Hedy! Say ' new_word
Up until this level the haunted house game always asked the player to choose a door, but as you might have noticed, they didn't really have to answer correctly. If the player filled in a completely random answer, the game would still work and the player might even win (despite not picking a door). In this level you can only win the game by picking the same door Hedy picked randomly.
Can you find the 4 missing words to complete the code?
print 'Escape from the haunted house!'
print 'There are 3 doors in front of you...'
doors is 1, 2, 3
monsters is werewolf, mummy, vampire, zombie
chosen_door is ask 'Which door do you choose?'
print 'You chose door...' chosen_door
sleep
correct_door is doors at random
_ _ _ _ print 'Great! Youve escaped!'
else print 'Oh no! You are being eaten by a...' monsters at random
In level 5 you can make a choice with if. For example between different types of figures.
print 'Drawing Figures'
figure is ask 'Do you want a square or a triangle?'
if figure is triangle angle is 120
else angle is 90
turn angle
forward 25
turn angle
forward 25
turn angle
forward 25
turn angle
forward 25
Fill in the correct numbers in this code to get it to work. After you've done that, you can try to add the option backwards.
Extra Instead of using 'left' and 'right', remake the program with North, East, South and West. This way you could add even more directions like Northeast and Southwest etc.
direction is ask 'Do you want to go left, right, or straight ahead?'
if direction is left turn _
if direction is right turn _
forward 100
Recreate the drawings with the turtle!
Extra Make only one code that lets the player decide which letter they'd like to see! And can you add even more letters?
Hint:
chosen_letter is ask 'Which letter would you like to see? F, E or L?'
if _
Debug this code. Good luck!
Warning! This code needs to be debugged!
print Welcome to Swimming Pool Hedy!
certificate is ask 'Do you have a swimming certificate?'
if certificate 'yes' print 'Great! You can swim in the pool!
print else 'You can enter, but you can't swim.'
discount is ask 'Are you younger than 12?'
if discount is yes
print 'That will be $3,50'
'That will be $5,50'
print 'Have a nice day!'
Our centre for burnwounds would like to lessen the workload by using an online triage tool. This way the patients can not only register their name and date of birth, but also what kind of burnwound they have (first, second or third degree) and advise on what to do next. Can you help them?
The program should:
An error occurred.
An error occurred.
Success
Header
Waiting for a keypress...
Sleeping...
You must be logged in to hand in an assignment.