Buy:
|
Scratch 'Shakespearean Compliment Generator' Tutorial
Click here for lesson guide
How it works
The program works by taking the familiar Shakespearean sonnet ‘Shall I compare thee to a summer’s day?’ but replaces the last two words with a random adjective followed by a random noun.
Introduction:
In this tutorial, you will learn how to make a 'Shakespearean' style compliment generator in Scratch.
Step 1
Look at the sample code (below) and try to work out what the code is doing. Click play button (right) to see if you where right.
In this tutorial, you will learn how to make a 'Shakespearean' style compliment generator in Scratch.
Step 1
Look at the sample code (below) and try to work out what the code is doing. Click play button (right) to see if you where right.
Did you guess right?
Challenge 1
Click on the code sample link below and modify the sorting hat code by changing the house names.
Sample code:
https://scratch.mit.edu/projects/622233705
Challenge 1
Click on the code sample link below and modify the sorting hat code by changing the house names.
Sample code:
https://scratch.mit.edu/projects/622233705
Step 2
Question: Can you spot a problem with your code?
Fixing your code
Did you notice that your program never picked Dumbledore?
Let's take a look at the first line to see what the problem is.
- Add a new house to your list called 'Dumbledore' and run the code again.
Question: Can you spot a problem with your code?
Fixing your code
Did you notice that your program never picked Dumbledore?
Let's take a look at the first line to see what the problem is.
Notice that our code picks a random number between one and four. However, our list now contains five items.
Challenge 2
Hint: You will need to change the last number in the first line!
Step 3
What if we keep adding to the list or we are not sure how many items are in our list?
We can get around this problem by returning the length of the list. For example:
Challenge 2
- Modify your code so that it now also picks Dumbledore from the list.
Hint: You will need to change the last number in the first line!
Step 3
What if we keep adding to the list or we are not sure how many items are in our list?
We can get around this problem by returning the length of the list. For example:
Challenge 3
Extra Challenge
- Modify your code so that it picks a random number between one and the length of the list (see example above).
Extra Challenge
- Modify your code so that it picks a name at random from your whole class.
Shakespearean Compliment Generator
Remember: The compliment generator works by taking the familiar Shakespearean sonnet ‘Shall I compare thee to a summer’s day?’ but replaces the last two words with a random adjective followed by a random noun.
Challenge
Using the partially completed example below, create your very own Shakespearean compliment (or insult) generator.
Example:
Remember: The compliment generator works by taking the familiar Shakespearean sonnet ‘Shall I compare thee to a summer’s day?’ but replaces the last two words with a random adjective followed by a random noun.
Challenge
Using the partially completed example below, create your very own Shakespearean compliment (or insult) generator.
Example:
Worked example (containing missing elements of the code):
https://scratch.mit.edu/projects/622707721
https://scratch.mit.edu/projects/622707721
Example solution:
scratch.mit.edu/projects/622705185
scratch.mit.edu/projects/622705185