Oxymoron Machine

An oxymoron, a literary device, is a pair of words that are opposites. You can use them in your creative writing to add emphasis to a point you want to make. Here is an example:

Why then, O brawling love, O loving hate...

O heavy lightness, serious vanity...

Feather of lead, bright smoke, cold fire, sick health...

-Romeo in Romeo annd Juliet by William Shakespeare, Act 1, lines 179, 181, 183

Do you see the pairs of opposites in the lines above? Each of those pairs is called an oxymoron.

The character Romeo uses these opposites to describe the conflicting emotions he experiences as part of being in love. Perhaps one of the most famous oxymorons also comes from Romeo and Juliet when Juliet says that “Parting is such sweet sorrow”, meaning that even though parting (saying goodbye) is sad, there is a sweet or tender emotion in the experience as well.

Think of some other examples of oxymorons. Are you a “cheerful pessimist”? Or have you ever watched a show about zombies, who are the “living dead”?

Using a programming language called Python, you’ll build an Oxymoron Machine that displays a list of oxymorons.

  1. Step 1

    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!

  2. Step 2

    Now that we know about variables and values, we need to translate our oxymorons into code.

    In the oxymorons from Romeo and Juliet, the first word is an adjective. For example, “loving” in “loving hate” is an adjective. The second word in these oxymorons is a noun. For example, “hate” in “loving hate” is a noun. We are going to create two variables. The first variable is going to be our list of adjectives (the first word in the oxymorons) and the second variable will be our list of nouns (the second word in the oxymorons).

    On lines 2-3, type:

    adjectives = [“brawling”, “loving”, “heavy”, “sweet”]

    nouns = [“love”, “hate”, “lightness”, “sorrow”]

  3. Step 3

    Indexing

    Now we’re going to learn about indexing in Python. Indexing means that every value in a list has a number automatically assigned to it. For the first value in a list, that number is always 0. The second item in the list is 1, the third item in the list is 2, and so on.

    The cool thing about indexing is that, because a number is assigned to a value, when you do things with those numbers you are doing things with the values.

    If we were to present our lists of adjectives and nouns using their index numbers, our lists would look like this:

    adjectives = [0,1,2,3]
    nouns = [0,1,2,3]

    The first word in our list of adjectives--that is, the first value in that list--is “brawling”. Its index number is 0. The first word or value in our list of nouns is “love”. Its index number is also 0. “Brawling” and “love” are at index number 0 in their respective lists.

    To “call” an item that corresponds to a given index number in a list, all we need to do is type the name of the list--the variable name--and put the index number next to it in brackets. So, if we want to “call” the word “brawling”, and its index number is 0 in a list named “adjectives”, our code would look like this:

    adjectives[0]

    If this is all we want to display as our output, we can invoke, or use, the print function. We can put whatever we want to display in parentheses, like this:

    print(adjectives[0])

    We can even assign adjectives[0] to its own variable, like this:
    word = adjectives[0]

    If you do this, then you can just print the name of the variable, word, to get the same results as if you had printed adjectives[0]. In the code editor on the right, go to the Indexing section and uncomment, or remove the hashtags from, the code on lines 19-21.

    Run the program to see the results!

  4. Step 4

    Now that you’ve learned about indexing in Python, you’re ready to write some more code for our oxymoron machine. Let’s teach our program our oxymoron formula:

    oxymoron = adjective + noun

    Now we need to type the name of our new variable, oxymoron. If we want our oxymoron to be “equal to” the first word in our list of adjectives plus the first word in our list of nouns, what might we need to write as the value of that variable? In other words, what do we need to put on the right side of the equals sign? Write your code on line 5 in your code editor.

    There’s one more thing we need to add. We want to have a space between adjectives[0] and nouns[0]. Otherwise the program will put the words “brawling” and “love” right next to each other, without any space between the words. Add a space by formatting your code this way:

    oxymoron = adjectives[0] + “ ” + nouns[0]

    When we “add together” parts of code using the + symbol, we are concatenating the parts of code.

  5. Step 5

    Now we want to print, or display, our oxymoron. Use the print function to do this and run the program.

  6. Step 6

    Now that you know how to display the first oxymoron in our list--”brawling love”--it’s time to do the same for the other oxymorons.

    Instead of having just one oxymoron variable, we’re going to have four. That means we need to change our variable name on line 7 just slightly. Let’s change it to oxymoron_1, as it’s going to be the first of four oxymorons.

    Move on to line 9. Now we need to write the code for our second oxymoron. Any guess as to what the code will be?

    If you guessed oxymoron_2 = adjectives[1] + “ ” + nouns[1], you’re right! Now write the code for oxymoron_3 and oxymoron_4. You should have a line of code for each oxymoron.

  7. Step 7

    Can you guess what we need to do next? We need to “print” all of our oxymorons. Right now we can only see the first one if we run our program.

    We have a couple of options for doing this. If you want your oxymorons to all display in a horizontal list, with a comma and a space after each oxymoron, you can write your code this way:

    print(oxymoron_1 + “, ” + oxymoron_2 + “, ” + oxymoron_3 + “, ” + oxymoron_4)

    If you want your oxymorons to stack on top of each other in a vertical list, you can write your code this way:

    print(oxymoron_1)

    print(oxymoron_2)

    print(oxymoron_3)

    print(oxymoron_4)

    Either way you choose to format the code, when you run your program, you should get a list of all 4 oxymorons.

View Solution

Teaching Ideas

  • Key terms & concepts: oxymoron, figurative language, Python, variable, value, module, random module, string, function, print function, array, indexing, concatenate
  • Discuss why we use figurative language like oxymorons. How does this device communicate an idea in a way that perhaps literal, non-figurative language doesn’t?
  • To explore oxymorons further, have students find examples in popular culture, like song lyrics.
  • Discuss oxymoron examples from literature you are reading in class. You can use oxymorons from a literature unit instead of the ones given here to complete this project.
  • Instead of using the oxymorons given here, have students generate their own oxymorons in small groups or as a class. If in small groups, have each student come up with 1-5 nouns and write them on index cards. Then have students look at the words and brainstorm opposing adjectives to pair with the nouns.
  • Have students write critical analysis short responses, or fuller essays, about the role of oxymorons 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