Shakespearean Compliment Generator
- Understand and use sequence in an algorithm
- Understand and use iteration in an algorithm (FOR and WHILE loops)
- Understand and use selection in an algorithm (IF, Else and Else if)
- 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.
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.
coinFlip = ["Heads", "Tails"]
Next, share the following worked example. Have the students predict what will happen before running the code.
#Superhero name generator
firstname = ["Red", "Green", "Yellow"]
surname = ["Claw", "Spider", "Dynamo"]
print(random.choice(firstname) + " " + random.choice(surname))
Finally, challenge them to create a ‘Shakespearean compliment generator’ using what they have learnt.
If students struggle with this challenge, share with them this partial worked example:
#Shakespearean Compliment Generator
adjective = #Create a list of adjectives to choose from
noun = #Create a list of nouns to choose from
print("Shall I compare thee to a ")
#add code to select and print an adjective and noun at random to complete the sentence
Explain to the students that having very long lists is not very efficient, plus it makes the code more difficult to debug.
Challenge students to improve their solution by having a file for each list of nouns / adjectives.