Assignment 2
- Due Jul 12, 2017 by 11:59am
- Points 3
- Submitting a file upload
- File Types py and txt
1) Write a function both() that takes two strings and prints them in order, and then prints them in reverse order.
Calling both("one", "two") should print
one and two
two and one
2) Write a program that uses functions to print the first five verses of the Twelve Days of Christmas.
Please include a blank line between verses, as show below
You should have about a half dozen functions. Each function can include one or more print statements. The body of the program should call the functions you define: there should be no print statements outside your functions.
To minimize your work, only print the line "Three French Hens" from one function. Only print "Four Calling Birds" from one function. Each line of the song should appear only once in your program: one copy of "Two Turtle Doves", etc.
This is an exercise in writing functions, not in singing, so you may have deviations from the text. The two primary deviations are
- You may use "On the first day of Christmas" as the first line of each verse, rather than printing the correct day. We discussed a way to get around this limitation in class, but you do not need to implement it.
- You do not need to include the extra "And" before the last line of every verse except the first.
Here are the words:
On the first day of Christmas
My true love sent to me:
A Partridge in a Pear Tree
On the second day of Christmas
My true love sent to me:
Two Turtle Doves
And a Partridge in a Pear Tree
On the third day of Christmas
My true love sent to me:
Three French Hens
Two Turtle Doves
And a Partridge in a Pear Tree
On the fourth day of Christmas
My true love sent to me:
Four Calling Birds
Three French Hens
Two Turtle Doves
And a Partridge in a Pear Tree
On the fifth day of Christmas
My true love sent to me:
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves
And a Partridge in a Pear Tree