Creating a Shakespearen Insult Generator – Part 1 (Python Tutorial)
How to make a Shakespearean insult
To make a Shakespearean insult, pick one word from each of the columns (below), combine them to make a sentence and add the word “Thou” at the beginning. For example: If we were to take the first word from each of the 3 columns we would get:
Before creating your Shakespearean insult generator, let's explore the random function in Python.
Let's start by writing a program to simulate the flipping of a coin.
Type in the following code in the code window (below):
cointoss = random.randint(1,2)
if cointoss == 1:
Modify your code to simulate the rolling of a dice i.e. if the random function returns a 6, print the word “Six”.
Let's create a random name picker. This will form the basis of your Shakespearean Insult generator.
Type in and run the following code:
names = ["Bob", "Dave", "Stuart"]
Comment your code, using the hashtag (#), explaining what the code is doing and why the random generator is returning a value between 0 and 2 rather than 1 and 3.
Did you know?
Lists start at 0 NOT 1.
e.g. if we were to run the following code:
The computer would return the name “Bob”
Replace the last line with the following new code:
Run the new script and explain what the new code does.
Finally, we need to add (concatenate) the word “Minion” at the beginning of our randomly selected name.
Replace the last line with the following:
print(“Minion” + “ “ + random.choice(names))
Add some more names to the list.
You now have all the components you need to create your very own Shakespearean insult generator.
Using what have learnt and using all the resources at your disposal, create your very own Shakespearean Insult generator.
Tip: You will need to create three lists (one for each set of words). For example:
Support: If you prefer, I have provided a template with the lists already created (see below) – this will save you from having to type all the words in each list.
Unless otherwise specified, everything in this repository is covered by the following licence:
Based on the Shakespearean Insulter: http://www.pangloss.com/seidel/Shaker/