""" Author: Sohie Lee Date: Spring 2022 Purpose: Lab03, Fruitful String Functions Filename: poem.py SOLUTIONS """ import random def firstLine(): '''Returns a 5-syllable string for the first line of a haiku ''' base = 'you say you like ' noun = random.choice(['me', 'them']) return base + noun def thirdLine(): '''Returns a 5-syllable string for the third line of a haiku ''' line1 = 'believe you? never!' line2 = 'i gave you my heart' line3 = 'under the covers' line4 = 'classic betrayal' return random.choice([line1, line2, line3, line4]) def secondLine(): '''Returns a 7-syllable string for the middle line of a haiku ''' base = 'then you are ' verb = random.choice( ['eating ', 'singing ', 'dancing ', 'reading ', 'flirting '] ) descriptivePhrase = random.choice( ['with cats', 'outside', 'dirty', 'alone'] ) return base + verb + descriptivePhrase def poem(): '''Returns a string haiku -- three lines with 5, 7, and 5 syllables, respectively. ''' newline = '\n' return ( # parentheses allow line breaks firstLine() + newline + secondLine() + newline + thirdLine() + newline ) def haikuFlurry(): '''Returns a string containing 3 separate haikus with a blank line separating each poem. ''' newline = '\n' return poem() + newline + poem() + newline + poem()