'Quotation marks'
In level 4 ask and print have changed.
You must put text that you want to print between quotation marks.
This is useful, because now you can print all the words you want. Also the words you used to store something with is.
Most programming languages also use quotation marks when printing, so we are also getting a step closer to real programming!
print 'You need to use quotation marks from now on!'
answer is ask 'What do we need to use from now on?'
print 'We need to use ' answer
Contractions
Important! Mind that now that we're using quotation marks, Hedy will get confused when you use the apostrophe for contractions like I'm or What's. Make sure to use double quotes when you're using an apostrophe in your line! Check out the example code to see the wrong way of using apostrophes.
#This is the wrong way of using apostrophes
print 'I'm babysitting my sister's kids'
print 'What's more fun than that?'
#This is how you solve it
print "I'm babysitting my sister's kids"
print "What's more fun than that?"
# Try it out! Create a line of code with quotationmarks below
_
In this level we have to use quotation marks with the commands ask and print.
Exercise
Complete the code by filling in quotation marks on the blanks.
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
print _ 🧒 Say _ new_word _ , Hedy! _
print _ 🦜 _ words at random
Exercise
Copy the example code and finish it by adding quotation marks on the blanks in lines 1 and 2.
The blanks in line 3 and 4 should not be replaced by quotation marks, but a sleep and a clear command. Can you make it work?
Exercise 2
Go back to the previous level and copy your story code. Make the code work in this level by adding quotation marks in the right spots. Mind: The variables in your own story should be outside of the quotation marks. Just like the second line of the example code. In that line the variable name is placed outside of the quotation marks.
name is ask _ What is your name? _
print _ The main character is called _ name
_
_
print name _ is now going to walk in the woods _
print name _ is a bit scared _
animals is 🦔, 🐿, 🦉, 🦇
print _ He hears the sound of a _ animals at random
print name _ is afraid this is a haunted forest _
In this level you learn how to use quotation marks in your games.
Exercise
Can you make your Haunted House level 4 proof?
Exercise 2
Go back to the previous level and copy your haunted house code. Make the code work in this level by adding quotation marks in the right spots.
# Add quotation marks to this code
print Escape from the haunted house!
print There are 3 doors in front of you...
choice is ask Which door do you choose?
print You picked door ... choice
monsters is a zombie, a vampire, NOTHING YOUVE ESCAPED
print You see...
sleep _
print monsters at random
Exercise
We have removed all the quotation marks from this example code, can you add them in all the right places?
Exercise 2
Go back to the previous level and copy your fortune teller code. Make the code work in this level by adding quotation marks in the right spots.
# Add the quotation marks to this code
print I'm Hedy the fortune teller!
question is ask What do you want to know?
print This is your question: question
answers is yes, no, maybe
print My crystal ball says...
sleep _
print answers at random
In the restaurant you have to use quotation marks too when using the print or ask command.
Exercise
Add the quotation marks to this code to make it work! Be careful: variables should not be in quotation marks.
Then, use the clear command to only show one line at a time in your output screen.
Exercise 2
Go back to the previous level and copy your restaurant code. Make the code work in this level by adding quotation marks in the right spots and add some clear commands.
# Add the quotation marks to this code
print Welcome to Restaurant Chez Hedy!
print Today we are serving pizza or lasagna.
food is ask What would you like to eat?
print Great choice! The food is my favorite!
topping is ask Would you like meat or veggies on that?
print food with topping is on its way!
drinks is ask What would you like to drink with that?
print Thank you for your order.
print Your food and drinks will be right there!
sleep _
print Your food is ready! Here you go!
In level 4 you have to use quotation marks with print and ask. Also when drawing!
print _ Drawing figures _
angle is 90
turn angle
forward 25
turn angle
forward 25
You can also change the color of the lines with the command color. Check out the example.
You can also use the command color white to make 'invisible' lines. You could use these white lines to move the turtle anywhere in the screen before you start drawing.
Exercise
Make your own colored drawing!
color white
forward -80
color green
forward 50
color yellow
forward 50
color red
forward 50
Exercise
Recreate the drawings with the turtle!
Extra Up for a real challenge? Make sure that the colors of these figures are selected randomly, so that each time you run your programs they'll look differently!
colors is red, orange, yellow, green, blue, purple, pink, brown, gray, black
color _
Time for a new command! With clear you can clear all the text from your output screen. This way you can prevent your screen getting too full of text.
Beware! If you are using a clear command, you might need to use a sleep above it. Otherwise Hedy will clear your screen without giving you the time to read as you can see in the example!
print '3'
clear
print '2'
clear
print '1'
clear
print 'wait for it...'
sleep 3
clear
print 'SURPRISE!'
Use the clear command to create a karaoke machine!
Exercise
Finish the karaoke version of 'Mary had a little lamb'. Then, create a karaoke version of any song you'd like!
print 'Mary had a little lamb'
play E
play D
play C
play D
play E
play E
play E
clear
print 'Little lamb, little lamb'
play D
play D
play D
play E
play E
play E
clear
print 'Mary had a little lamb'
play E
Decorate the living room the way you want it to be!
Exercise
Ask the player at least 6 more questions about their dream living room. You could, for example, ask them what type of couch they would like, how big the dining table should be, what kind of art they want on their walls etc. Then use that information in the describtion of the house. So if you've asked about their tv, write a line about what kind of tv they have chosen.
print "Let's redecorate the living room!"
#Asking the player for input
color_walls is ask 'What color would you like the walls to be?'
color_carpet is ask 'What color would you like the carpet to be?'
type_couch _
#Describtion of your dream house
print 'Your house will have ' color_walls ' walls and a ' color_carpet ' carpet.'
print _
Create a party planning tool that creates an invite to your party!
Execrise
- First fill in the right questions to ask the player
- Then create a party invitation using the input the player gave you
#asking for input
print 'PARTY PLANNER'
name_host is ask _
name_guest is ask _
reason_party is ask _
date_party is ask _
time_party is ask _
location_party is ask _
theme_party is ask _
dress_code is ask _
#loading the invite
print 'please wait... loading invite'
sleep 2
clear
#printing the invite
print 'Dear ' name_guest ','
_
Make a monster generator. Ask the player questions about what they want their monster to be like and then generate a story for them.
Exercise
- Create at least 5 more questions about the monster
- Create a (fake) loading screen, that shows the word 'Generating...' for 3 seconds and then clears the screen.
- Write the rest of the story using the new variables you've made.
# Welcome and questions
print 'Welcome to the monster generator!'
name_monster is ask 'What is your monster called?'
adjective_monster is ask 'How would you describe your monster?'
color_eyes is ask 'What color eyes does your monster have?'
amount_of_eyes is ask 'How many eyes does your monster have?'
_ Create more questions here _
# Generating
_ Create a loading screen _
# Write a story about the monster
print 'This is ' name_monster ' the ' adjective_monster ' monster'
print name_monster ' has ' amount_of_eyes ' ' color_eyes ' eyes'
_ Write the rest of the story including your new variables _
Exercise
Debug this code. Good luck!
Warning! This code needs to be debugged!
print 'Welcome to the online library!
ask What genre of books do you like?
print You like genre
author is ask 'Who's your favorite author?'
print 'author is your favorite author'
print Hmmm... I think you should try... books at random
Our nurses have a lot of tasks to accomplish in one day. One of these tasks is going around all the patients in the morning and ask them what they would like to have for breakfast. Can you lessen the workload of our nurses by creating a program in which the patients choose their breakfast and send their order directly to the kitchenstaff?
Exercise
The program has to:
- Ask the patient to enter their name and roomnumber
- Greet the patient by their name
- Display all the food (sandwiches, cereal, fruit etc.) and drinks on the menu
- Ask the patient what they would like to eat
- Ask them what they would like to drink
- Repeat the order back to the patient
- Thank the patient for ordering
- Tell them that their order will be brought to their roomnumber in 15 minutes.
An error occurred.
An error occurred.
Success
Header
Waiting for a keypress...
Sleeping...
Hand in exercise
You must be logged in to hand in an assignment.