Scratch 'Shakespearean Compliment Generator' Lesson
NOTE: A self-guided (in-browser) tutorial version of this lesson (suitable for remote learning) can be found by here:
Shakespearean complement generator tutorial
How it works
- Understand and use sequence in an algorithm
- Understand and use data structures in an algorithm (for example, Lists, Tables or Arrays)
EDUCATOR: COMPUTATIONAL THINKING COMPETENCIES:
COMPUTER SCIENCE EDUCATORS:
CSTA K–12 CS Standards:
AREA OF LEARNING AND EXPERIENCE: Science and Technology:
Computation is the foundation for our digital world.
Progression step 3
- I can use conditional statements to add control and decision-making to algorithms.
- I can identify repeating patterns and use loops to make my algorithms more concise.
- I can explain and debug algorithms.
Progression step 4
- I can decompose given problems and select appropriate constructs to express solutions in a variety of environments.
- I can select and use data structures that efficiently manage data in algorithms.
- I can plan and implement test strategies to identify errors in programs.
Progression step 5
- I can identify, define and decompose problems, choose appropriate constructs and express solutions in a variety of environments.
- I can use file-handling techniques to manipulate data in algorithms.
- I can test, evaluate and improve a solution in software.
In this lesson, students will make a 'Shakespearean' style compliment generator.
Start by sharing the following code for a simple sorting hat. Challenge the students to predict what will happen before revealing the answer.
Have the students launch the code sample (for a simple sorting hat) below then modify it by changing the house names.
Ask the students to add a new house to their list called 'Dumbledore' and run the code again. Ask the students if they can spot a problem with their new code.
Explain that there is a problem with the code in that it will never pick Dumbledore.
Highlight the first line (set random) and explain that the code picks a random number between one and four, however our list now contains five items.
Ask the students to modify their code so that it now also picks Dumbledore from the list.
Ask the students, what if we keep adding to the list or we are not sure how many items are in our list?
Explain that we can get around this problem by returning the length of the list. For example:
Ask the students to modify their code so that it picks a random number between one and the length of the list (see example above).
Taking it further
Challenge the students to modify their code so that it picks a name at random from their whole class.
Explain how the compliment generator works (see description above) and share the worked example below. Challenge the students to create their own compliment (or insult) generator using what they have learnt or by using the worked example (below).