IniziaInizia gratis

Single-parameter functions

Congratulations! You have successfully defined and called your own function! That's pretty cool.

In the previous exercise, you defined and called the function shout(), which printed out a string concatenated with '!!!'. You will now update shout() by adding a parameter so that it can accept and process any string argument passed to it. Also note that shout(word), the part of the header that specifies the function name and parameter(s), is known as the signature of the function. You may encounter this term in the wild!

Questo esercizio fa parte del corso

Introduction to Functions in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Complete the function header by adding the parameter name, word.
  • Assign the result of concatenating word with '!!!' to shout_word.
  • Print the value of shout_word.
  • Call the shout() function, passing to it the string, 'congratulations'.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Define shout with the parameter, word
def shout(____):
    """Print a string with three exclamation marks"""
    # Concatenate the strings: shout_word
    ____ = ____ + '!!!'

    # Print shout_word
    print(____)

# Call shout with the string 'congratulations'
Modifica ed esegui il codice