Funções com vários parâmetros
Na última aula, Hugo discutiu o uso de vários parâmetros na definição de funções. Agora você usará o que aprendeu para modificar ainda mais a função shout()
. Aqui, você modificará shout()
para aceitar dois argumentos. Partes da função shout()
, que você escreveu anteriormente, são mostradas.
Este exercício faz parte do curso
Introdução a funções em Python
Instruções de exercício
- Modifique o cabeçalho da função de modo que ela aceite dois parâmetros,
word1
eword2
, nessa ordem. - Concatene
word1
eword2
com'!!!'
e atribua ashout1
eshout2
, respectivamente. - Concatene
shout1
eshout2
juntos, nessa ordem, e atribua anew_shout
. - Passe as strings
'congratulations'
e'you'
, nessa ordem, para uma chamada parashout()
. Atribua o valor de retorno ayell
.
Exercício interativo prático
Experimente este exercício preenchendo este código de exemplo.
# Define shout with parameters word1 and word2
def shout(____, ____):
"""Concatenate strings with three exclamation marks"""
# Concatenate word1 with '!!!': shout1
# Concatenate word2 with '!!!': shout2
# Concatenate shout1 with shout2: new_shout
# Return new_shout
return new_shout
# Pass 'congratulations' and 'you' to shout(): yell
# Print yell
print(yell)