0% found this document useful (0 votes)
14 views

Girls Who Code at Home - Python Poetry - Reference Guide

Uploaded by

ifunanyaijah2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Girls Who Code at Home - Python Poetry - Reference Guide

Uploaded by

ifunanyaijah2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Girls Who Code At Home

Python Poetry
Reference Guide
Python Poetry - Reference Guide
In this document you will find sample answers to some of the questions in the activity.
Follow along with the activity and when you see this icon, stop and crosscheck your ideas
here.

Step 1: What is Poetry?


Choose a Poem
We encourage you to choose a short poem that is meaningful to you! Below is an example of a poem by
Langston Hughes called, Dreams.

Write your Poem Below

Hold fast to dreams


For if dreams die
Life is a broken-winged bird
That cannot fly.

Hold fast to dreams


For when dreams go
Life is a barren field
Frozen with snow.

If you are having difficulty choosing a poem, don’t forget to explore some of the poems below!
➔ Poets.org
➔ PoetryFoundation.org
➔ ButtonPoetry.com
➔ FamousPoetsAndPoems.com

2
Step 3: Introduction to Python
Use the sample code below to reflect on how to use comments in Python.

Sample Code:

1. # This is a comment
2. print(“Hello World.”)
3. # Here we can write anything without the computer reading our messages
4. message = “hi”

Reflect
Take a moment to review the code snippet above. Which lines of code are comments? How do you
know? Remember, you can refer to the specific lines of code by their line number.

Line #1 and #3 are comments in Python. We know that these two lines are comments because they start
with the a # symbol.

Step 4: Print Statements in Python


You Try: Print your Poem
Once you choose your poem, it is time to print your poem in Python. We learned that the format and
structure of poems are very important to the art. Below we shared the code for creating new lines in
Python using both methods! We will continue to use our poem from above, Dreams.

➔ Use multiple print() statements:

Sample Code:

1. print(“Hold fast to dreams”)


2. print(“For if dreams die”)
3. print(“Life is a broken-winged bird”)
4. print(“That cannot fly.”)
5. print(“Hold fast to dreams”)
6. print(“For when dreams go”)
7. print(“Life is a barren field”) 3
8. print(“Frozen with snow.”)
Step 4: Print Statements in Python (cont.)

➔ Use the \n command:

Sample Code:

1. print(“Hold fast to dreams\nFor if dreams die\nLife is a broken-winged bird\nthat cannot


fly. Hold fast to dreams\nFor when dreams go\nLife is a barren field\nFrozen with snow.”)

Step 5: Create a Poem Generator


Determine User Input
Use this table to help determine which words will be the variables in your poem. Here is an example of
what your table would look like if you used the poem, Dreams.

Word #1 What prompt will your user see?

Type in an animal.
Bird

Word #2 What prompt will your user see?

Type in a verb that your animal would do.


Fly

Word #3 What prompt will your user see?

Type in something cold.


Snow

4
Step 5: Create a Poem Generator (cont.)

Reflect
When you run your program, what is different about the output section of Replit?

There is a flashing bar in the output window that allows you to type something in.

What is the difference between a print() command and an input()command?

A print() command lists a string in the output window. An input() command allows the user to type
in feedback to the string.

Variables in Python
Use this table to create variable names for each of the words the user will replace.

Word #1 Variable Name

Bird animal

Word #2 Variable Name

Fly verb

Word #3 Variable Name

Ice cold

You Try: Assign Variable Names


At this point in the program you should have three variables assigned to input() commands. Below we
shared the code for assigning variables in Python.

Sample Code:

1. animal= input(“Type in an animal.”)


2. verb= input(“Type in a verb that your animal would do.”)
3. cold= input(“Type in something cold.”)

5
Step 6: Displaying the New Poem
You Try: Print your Customized Poem
Below we shared the code for how to complete your program. You can check out our full sample project
for more ideas!

Sample Code:

1. animal= input(“Type in an animal.”)


2. verb= input(“Type in a verb that your animal would do.”)
3. cold= input(“Type in something cold.”)
4. print(“Hold fast to dreams”)
5. print(“For if dreams die”)
6. print(“Life is a broken-winged ” +bird)
7. print(“That cannot ” +verb+ “.”)
8. print(“Hold fast to dreams”)
9. print(“For when dreams go”)
10. print(“Life is a barren field”)
11. print(“Frozen with ” +cold+ “.”)

Step 7: Extensions
Extension 1: Add More Variables into your Poem (5 mins)
Check out our full extension project for more ideas!

Extension 2: Format your Poem with the Tab Command (5 mins)


Check out our full extension project for more ideas!

Extension 3: Add Wait Time to your Poem (5 mins)


Check out our full extension project for more ideas!

You might also like