Qual função retorna o maior número?
Sua função receberá duas funções, f e g, que não aceitam nenhum parâmetro. Sua função deve chamá-las e retornar uma string que indique qual função retornou o maior número.
- Se
fretornar o maior número, retorne a stringf. - Se
gretornar o maior número, retorne a stringg. - Se as funções retornarem o mesmo número, retorne a string
neither.
Exemplos
which_is_larger(lambda: 5, lambda: 10) ➞ "g"
which_is_larger(lambda: 25, lambda: 25) ➞ "neither"
which_is_larger(lambda: 505050, lambda: 5050) ➞ "f"Observações
Este exercício foi criado como uma introdução a funções de ordem superior (funções que usam outras funções para realizar seu trabalho).