Choose a random word from a group with at and random.
add an item to a list.
remove an item from a list.
Introduction
random
Dice
Rock, paper, scissors
music
Fortune teller
Restaurant
add to & remove from
Parrot
Dishes?
Story
Haunted House
Turtle
Draw it!
debugging
Puzzle
Quiz
In the previous level you've learned what a variable is and how you can use it to make your adventures more interactive.
But... that's not the only thing you can do with variables! You can also use variables to make lists.
And you can even let Hedy pick a random word out of a list, which allows you to make real games!
Take a quick look at the next adventure!
At random
In this level you can make a list using the is command. You can let the computer choose a random item from that list. You do that with at random.
animals is dogs, cats, kangaroos
print animals at random
You can use the at random command in a sentence as well.
food is sandwich, slice of pizza, salad, burrito
print I am going to have a food at random for lunch.
Exercise
Try out the at random command by making your own gameshow (like the ones on tv) where you choose a door or suitcase and it contains a big price!
Can you do it? We have already put the first lines into the example code.
print The big gameshow!
print There are 3 suitcases in front of you...
chosen is ask Which suitcase do you choose?
prices is _
_
In this level we can choose from a list. With that we can let the computer choose one side of the die.
Take a look at the games you have in your closet at home.
Are there games with a (special) die? You can also copy it with this code.
For example, the dice of the game Earthworms with the numbers 1 to 5 and an earthworm on it.
choices is 1, 2, 3, 4, 5, earthworm
print You threw _ at random !
Exercise
The dice in the example above are dice for a specific game. Can you make normal dice?
Or other special dice from a different game?
choices is _
You can use the at random command to let the computer pick rock, paper or scissors!
Exercise
Finish the code by using the at random command.
choices is rock, paper, scissors
print choices _
Extra Make a two player game. Firstly ask the two players to fill in their names. Then let the computer randomly pick their choices.
choices is rock, paper, scissors
player_1 is ask Name of player 1:
_
Create a random melody!
Exercise
The example code creates a random melody, but it's very short and not many notes are used.
Add more notes to the list and create a longer melody by copying the last line a couple more times.
notes is A4, B4, C4
play notes at random
play notes at random
play notes at random
In the previous levels you've created your first fortune telling machine, but Hedy couldn't really predict anything, only echo.
In this level you can use a variable and the at random command to really let Hedy choose an answer for you. Check out this code for instance:
print I’m Hedy the fortune teller!
question is ask What do you want to know?
print This is what you want to know: question
answers is yes, no, maybe
print My crystal ball says...
sleep 2
print answers at random
Exercise
Now, Hedy can only answer yes, no or maybe. Can you give Hedy more answer options, like 'definitely' or 'ask again'.
Having trouble to decide what you wanna have for dinner? You can let Hedy choose for you!
Simply add lists of your favorite (or least favorite) meals and Hedy can randomly choose your dinner.
You can also have a bit of fun, by letting Hedy choose the price for your dinner as well! What will you get?
dishes is spaghetti, brussels sprouts, hamburgers
print You will have dishes at random tonight!
prices is 1 euro, 10 euros, 100 euros
print That will be prices at random please.
Exercise
Now make your own version of the random restaurant.
Make a list of starts, mains, desserts, drinks and prices yourself.
Then use print and at random commands to tell the costumer what will be on their menu tonight.
print Welcome to your own random restaurant!
starters is _
mains is _
desserts is _
drinks is _
prices is _
_
Add to
You can add items to the list with the add to command. To add an item to a list you can simply type: add penguin to animals or you can use the ask command like in the example code.
animals is dog, cat, kangaroo
like is ask What is your favorite animal?
add like to animals
print I choose animals at random
Remove from
If you can add items to a list, of course you can also take them off. This is done with the remove from command.
animals is dog, cat, kangaroo
dislike is ask What animal do you not like?
remove dislike from animals
print I choose animals at random
Exercise
Try out the new commands in this virtual restaurant. Add the flavor the player is hoping for to the list and remove the flavors they are allergic to.
print Mystery milkshake
flavors is strawberry, chocolate, vanilla
hope is ask What flavor are you hoping for?
_
allergies is ask Are you allergic to any flavors?
_
print You get a flavors at random milkshake
Teach your parrot a new word with add.
Exercise
Can you add the add to command to get the code to work?
words is squawk, Hedy
print Train your parrot!
new_word is ask Which word do you want to teach them?
_ new_word _ words
print 🧒 Say new_word, Hedy!
print 🦜 words at random
Do you always disagree at home about who should wash the dishes or change the litter box today?
Then you can let the computer choose very fairly. You can program that in this level!
people is mom, dad, Emma, Sophie
print people at random has to do the dishes
Exercise
Make your own version of the dishwasher program. Firstly make a list of your family members.
Then think of a task that needs to be done, and let the computer decide who has to do the task with the at random command.
Extra Don't feel like doing the dishes yourself? Hack the program by removing your name from the list with the removefrom command.
In level 3 you can make your story more fun. You can use randomness for any monster, animal or other obstacle, like this:
animals is 🦔, 🐿, 🦉, 🦇
print They now hear the sound of an animals at random
The command add can also come in handy in your story.
print They hear a sound
animals is 🐿, 🦔, 🦇, 🦉
animal is ask What do you think it is?
add animal to animals
print it was an animals at random
This is an example of the remove command in your story
Exercise
Copy your story from the previous levels into this level.
In this level you've learned 3 new commands at random , add to and remove from.
Add new lines of code to your story, so that all of the new commands are featured at least once in your story.
print His backpack got way too heavy.
print Inside were a bottle of water, a flashlight and a brick.
bag is water, flashlight, brick
dump is ask Which item should he dump?
remove dump from bag
In the previous levels you've made an introduction to your haunted house game, but as you might have noticed the story would always have a dreadful end.
In this level you can make your story more interactive by changing the outcome of the game; sometimes you'll get eaten, sometimes you'll escape!
Let Hedy decide randomly!
Exercise
Copy the example codes and fill in the blanks to make it work!
Extra This story is pretty straight forward, maybe you can spook it up a bit by adding a more exciting story.
Also you have very limited outcomes right now, there are only 3 options of what's behind the doors. Maybe you can think of more monsters to add to the list!
_ Escape from the haunted house!
_ There are 3 doors in front of you...
_ _ _ Which door do you choose?
_ You picked door ... choice
monsters _ a zombie, a vampire, NOTHING YOUVE ESCAPED
_ You see...
sleep
_ _ _ _
In this level you can use at random with the drawing turtle. A random choice makes the turtle walk a different path each time.
Use at random to choose a value from a list.
Exercise
Can you copy and paste lines 2 and 3 to create a longer random path?
angles is 10, 50, 90, 150, 250
turn angles at random
forward 25
Exercise
Recreate the drawings with the turtle!
Triangle
Star
Arrow
Welcome to a debugging adventure. Debugging a code means getting rid of mistakes in the code.
That means that in these debugging adventures, we will give you a code that does not work yet.
You will have to figure out what's wrong and correct the mistakes.
Exercise
Debug this code. Good luck!
Warning! This code needs to be debugged!
movie_choices is dracula, fast and furious, home alone, barbie
chosen_movie is movies at random
print Tonight we will watch chosen _movies
like ask Do you like that movie?
print Tomorrow we will watch something else.
add chosen_movie to movie_choices
print Tomorrow we will watch tomorrows_movie
tomorrows_movie is movie_choices at random
I'll go get the popcorn! print