Simile Generator

A simile is a kind of figurative language. Figurative language creates pictures in the reader's mind and communicates an idea in a beautiful way.

A simile compares two things using "like" or "as". For example: "Tranquil as a forest" (Disney's Mulan), "He snuck away like a thief", "She's as brave as a lion", "He's happy like a kid at Christmas."

For this project, you will use similes from literature. But using Python code, you'll scramble those similes--with entertaining results!

  1. Step 1

    Here are a few similes:

    “The horse was strutting like a prizefighter.” - Laura Hillenbrand
    “They watch the miners spilling out of warehouses with their lunch pails toward the mouth of the elevator like insects toward a lighted trap.” - Anthony Doerr
    “Her breath is like frozen air.” - Jessica Rhoades

    We are going to use Python, a programming language, to scramble these similes!

    The code editor on the right is where you’ll write your code for this project.

    To make our program, we will first need to split up our similes. Then we will tell the program to randomly combine together two halves of a simile to make a whole simile.

    Because we want the program to have the ability to randomly assign one half of a simile to another half, we need to tell our program to use Python’s random module. This module, or set of built-in Python files, allows the program to do things randomly.

    To tell our program to use Python’s random module, we need to import it. Try doing this yourself: On line 2 of the code editor on the right, write a direct command to tell your program to import the random module with this code:

    import random

    Next up, we’ll learn about variables and values.

  2. Step 2

    Variables and Values

    In Python, we have variables and values. Think of a variable as a box, and a value as something that goes inside the box. Here is an example of a variable and its value:

    animal = “cat”

    In this case, animal is the variable, and “cat” is its value. In fact, it is a specific type of value--a string. A value that has letters or characters and no numbers is a string type value. We put strings inside quotation marks. When we write a variable, we are declaring the variable.

    In this case, we can say that we are assigning the value of “cat” to the variable animal. The = is called the assignment operator. It’s not an “equals” sign in the sense that 2 = 2, but it does convey a relationship. We are basically saying that animal represents “cat”. That means that when we do something with animal, we are doing something with “cat”.

    For example, look at this code:
    print(animal)

    The print function tells the program to print, or display, something in the output area of our code editor. (A function is an action that we can do in Python.) Keeping in mind that animal represents “cat”, what do you think we’ll see if we print the value of animal?

    Try it yourself: In the code editor on the right, declare a variable called animal. Then assign it a value, like “cat” (or another animal, if you’re not a cat person). Then tell the program to print the variable. Click the large gray triangle button at the top of the editor to run your program and see the results!

    You can also have multiple words as part of a single value. For example:

    favorite_song = “Somewhere Over the Rainbow”

    Try typing the above code in the editor and then printing favorite_song.

    Note that variable names are lowercase. Use underscores when you need to include multiple words, as in favorite_song, cat_name, and so on.

    Sometimes we might want to have more than one value assigned to a variable. We might want to have a list of values, for instance. In Python, we can make a list, also called an array. For example:

    animal = [“cat”, “dog”, “bird”, “fish”]

    “Cat”, “dog”, “bird”, and “fish” are all values in the array. In this example, they are all single-word strings. But you can have multiple-word strings as values in an array, as well:

    favorite_songs = [“Somewhere Over the Rainbow”, “Happy Birthday”, “Imagine”]

    What do you think would be the result if you typed the above line of code in your code editor and then printed favorite_songs? Try it and see!

  3. Step 3

    Now that you know about variables and values, let’s create some for our simile generator. A simile is a comparison of two nouns. To make our simile generator, we need to have two lists of nouns that we can compare.

    First, let’s create two new variables. Each one is the name of a list. If we want to have two lists, list 1 and list 2, how would we format those as variable names? Type the variable names on lines 4 and 5 of your code editor.

    Now we need some values to assign to our variables. Let’s take a look at our similes:

    The horse was strutting like a prizefighter.
    The miners spilled out of warehouses with their lunch pails toward the mouth of the elevator like insects toward a lighted trap.
    Her breath is like frozen air.

    We need to split each of these similes so that the first noun phrase of each simile is in the first list, and the second noun phrase of each simile is in the second list. A noun phrase contains a noun (person, place, thing) and words that accompany it, such as articles (a/an/the), adjectives, verbs, and other parts of speech.

    Look at the similes again:

    The horse was strutting like a prizefighter.

    The miners spilled out of warehouses with their lunch pails toward the mouth of the elevator like insects toward a lighted trap.

    Her breath is like frozen air.

    Let’s take the noun phrases on the left of "like" and assign them as values to our first variable. Here’s a hint as to how to format these:

    list_1 = [“ ” , “ ”, “ ” ]

    We also need to assign values to our second list variable. Take the noun phrases on the right of "like" and assign them as list items to the second list variable. Use the same formatting as you did for list_1 to create your second list.

  4. Step 4

    Now that we have our two lists, with each list containing simile components, we need to tell our program to randomly pull an item from each list. We do this by using Python’s random module.

    On lines 7 and 8, we are going to make two new variables. Each variable is going to contain just one item, or value. Type the following code on lines 7 and 8:

    part_1 = random.choice(list_1)
    part_2 = random.choice(list_2)

    The random.choice you see above is randomly pulling an item from the list in parentheses next to it and assigning that value to the new variable. So, the variable part_1 will have a value of an item from list_1 and the variable part_2 will have a value of an item pulled from list_2.

    This is where the “scrambling” happens--we won’t know what items the code assigned to part_1 and part_2 until the program runs!

  5. Step 5

    A basic simile follows this formula:

    simile = noun phrase 1 + “like” + noun phrase 2

    We want to teach this formula to our program. How might we do that, using what we know about variables and values? On line 10 try turning this formula into code.

    Then, on line 12, tell the program to print your simile. Then run your program and see what happens!

  6. Step 6

    Now your simile generator is all set up and ready to use. All you have to do is run your program as many times as you want to see different similes. You may even end up seeing the original, unscrambled similes! It all depends on what values the program chooses to randomly pull from list_1 and list_2.

View Solution

Teaching Ideas

  • Key terms & concepts: Figurative language, simile, Python, value, variable, module, random module, string, function, print function, array, noun phrase
  • Discuss the difference between similes and metaphors.
  • Discuss why we use figurative language like similes and metaphors. How do these devices communicate an idea in a way that perhaps literal, non-figurative language doesn’t?
  • To explore similes further, have students find examples in popular culture, like song lyrics.
  • Discuss different simile structures and how in this project we are using just one type of structure: noun phrase + like + noun phrase.
  • Instead of using the similes provided to complete the project, have students use examples from literature they are reading in class or their own original similes.
  • Generate simile ideas in small groups or as a class: Have each student come up with 5-10 nouns and write them on index cards. If in a small group, students show each other their cards and decide which could be paired as similes. Discuss the idea of abstraction, and how we’re not looking for literal similarity, i.e. “lemons are like oranges because they’re both citrus fruits”, but rather figurative similarity.
  • Have students write short responses or essays about the role of similes in a piece of literature.

Teaching Standards

ELA Common Core Standards (U.S.)

Reading Standards for Literature, 6-12–Grades 9-10 Students, #4(Pg 38):

  • Determine the meaning of words and phrases as they are used in the text, including figurative and connotative meanings; analyze the cumulative impact of specific word choices on meaning and tone (e.g., how the language evokes a sense of time and place; how it sets a formal or informal tone).

Reading Standards for Literature 6-12–Grades 11-12 Students, #4(Pg 38):

  • Determine the meaning of words and phrases as they are used in the text, including figurative and connotative meanings; analyze the impact of specific word choices on meaning and tone, including words with multiple meanings or language that is particularly fresh, engaging, or beautiful. (Include Shakespeare as well as other authors.)

Reading Standards for Informational Text 6-12

  • Grade 6 students #4 (Pg 39): Determine the meaning of words and phrases as they are used in a text, including figurative, connotative, and technical meanings.
  • Grade 7 students #4 (Pg 39): Determine the meaning of words and phrases as they are used in a text, including figurative, connotative, and technical meanings; analyze the impact of a specific word choice on meaning and tone.
  • Grade 8 students #4 (Pg 39): Determine the meaning of words and phrases as they are used in a text, including figurative, connotative, and technical meanings; analyze the impact of specific word choices on meaning and tone, including analogies or allusions to other texts.

Python References

For help with learning Python, check out these resources:

  • Think Java and Python for Everybody, both available for free at trinket.io
  • Head First Learn to Code: A Learner’s Guide to Coding and Computational Thinking by Eric Freeman
  • Impractical Python Projects: Playful Programming Activities to Make You Smarter by Lee Vaughan
  • Mosh Hamedani’s YouTube tutorial “Python Tutorial - Python for Beginners [2020]”
  • W3Schools.com - Website with information about many programming languages, including Python

Sitemap