Learn Python: Functions - Lesson 11, Review

https://www.codecademy.com/paths/computer-science/tracks/cspath-intro/modules/cspath-python-functions/lessons/intro-to-functions/exercises/review

Example of the song written as sang, this should help with the topic but as well expand further understanding of the topic as such so it can be understood deeper.

def repeat_stuff(stuff,num_repeats = 2):
return stuff * num_repeats
lyrics = repeat_stuff("Row ", 3) + "Your Boat. "
song = repeat_stuff(lyrics)
print(song)

def repeat_stuff(stuff,num_repeats = 2):
return stuff * num_repeats
lyrics = repeat_stuff("Gently ", 1) + "Down the stream. "
song = repeat_stuff(lyrics)
print(song)

def repeat_stuff(stuff,num_repeats = 2):
return stuff * num_repeats
lyrics = repeat_stuff("MERILY, ", 4)
song = repeat_stuff(lyrics)
print(song)

def repeat_stuff(stuff,num_repeats = 1):
return stuff * num_repeats
lyrics = repeat_stuff("Life ", 1) + β€œis but a dream!”
song = repeat_stuff(lyrics)
print(song)

Largest changes made here were to the Fx parameter repeats but as well to the lyrics and lyric defined variable call.

i.e - repeat_stuff("MERILY, ", 4)
repeat_stuff("Life ", 1)

1 Like

This is set as an example to simply expound on the topic more in depth.

1 Like

Could you press the button:
image
and paste the code between the three ``` signs, when editing the post, this would appear as code so it would allow indentation.

Largest changes made here were to the Fx parameter repeats but as well to the lyrics and lyric defined variable call.

i.e - repeat_stuff("MERILY, ", 4)
repeat_stuff("Life ", 1)

Here is an update for better notation quality.
1 Like