Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab.24 Your task is to write several functions that printthe lyrics of one of the best songs of all time to standard output.Rock-n-roll songs typically

Lab.24 Your task is to write several functions that printthe lyrics of one of the best songs of all time to standard output.Rock-n-roll songs typically follow a verse?chorus form, where theverse is unique, but the chorus is repeated verbatim. Instead ofwriting the chorus text over and over, we will use a function. Wewill define the main function stub for you, your task is to writethe body of the main function and the remaining 4 functions toimplement the following song structure:

verse 1

chorus

verse 2

chorus

verse 3

chorus

We defined the lyrics strings for you. Print a newline betweensections so it is easier to differentiate between verses and thechorus.

MY CODE:

verse1_lyrics = """Sitting on a cornflake, waiting for the vanto comeCorporation tee-shirt, stupid bloody TuesdayMan, you've been a naughty boy, you let your face growlong"""verse2_lyrics = """Mister City, policeman sittingPretty little policemen in a rowSee how they fly like Lucy in the Sky, see how they runI'm crying, I'm crying"""verse3_lyrics = """Sitting in an English garden waiting for thesunIf the sun don't come, you get a tanFrom standing in the English rain"""chorus_lyrics = """I am the egg man, they are the egg menI am the walrus, goo goo g'joob"""

def main(): verse1() chorus() verse2() chorus() verse3() chorus()# these functions should print to standard output# they should take no parameters, and instead use the stringsdefined at the top level scopedef main(): # call other functions here verse1() chorus() verse2() chorus() verse3() chorus() print()

# these functions should print to standard output# they should take no parameters, and instead use the stringsdefined at the top level scopedef verse1(): print(verse1_lyrics) print()def verse2(): print(verse2_lyrics) print()def verse3(): print(verse3_lyrics) print()def chorus(): print(chorus_lyrics)main()

image

image

What is the problem with my code and how I can change it to getthe expected output above?

Output is nearly correct; but whitespace differs. See highlights below. Special character legend Your output Expected output Sitting on a cornflake, waiting for the van to come Corporation tee-shirt, stupid bloody Tuesday Man, you ve been a naughty boy, you let your face grow long I am the egg man, they are the egg men I am the walrus, goo goo g joob Mister City, policeman sitting Pretty little policemen in a row See how they fly like Lucy in the Sky, see how they run I m crying, I m crying I am the egg man, they are the egg men I am the walrus, goo goo g joob Sitting in an English garden waiting for the sun If the sun don t come, you get a tan From standing in the English rain I am the egg man, they are the egg men I am the walrus, goo goo g joob Sitting on a cornflake, waiting for the van to come Corporation tee-shirt, stupid bloody Tuesday Man, you ve been a naughty boy, you let your face grow long I am the egg man, they are the egg men I am the walrus, goo goo g joob Mister City, policeman sitting Pretty little policemen in a row See how they fly like Lucy in the Sky, see how they run I m crying, I m crying Expected output I am the egg man, they are the egg men I am the walrus, goo goo g joob Sitting in an English garden waiting for the sun If the sun don t come, you get a tan From standing in the English rain I am the egg man, they are the egg men I am the walrus, goo goo g joob L Sitting on a cornflake, waiting for the van to come Corporation tee-shirt, stupid bloody Tuesday Man, you ve been a naughty boy, you let your face grow long I am the egg man, they are the egg men I am the walrus, goo goo g joob + Mister City, policeman sitting Pretty little policemen in a row See how they fly like Lucy in the Sky, see how they run I m crying, I m crying I am the egg man, they are the egg men I am the walrus, goo goo g joob J Sitting in an English garden waiting for the sun If the sun don t come, you get a tan From standing in the English rain I am the egg man, they are the egg men I am the walrus, goo goo g joob

Step by Step Solution

3.42 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

define the strings verse1lyrics Sitting on a cornflake waiting for the van to come Corporation teesh... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management Science The Art Of Modeling With Spreadsheets

Authors: Stephen G. Powell, Kenneth R. Baker

4th Edition

978-1118517376, 9781118800348, 1118517377, 1118800346, 978-1118582695

More Books

Students also viewed these Programming questions