DEV Community

Cristian Fernando
Cristian Fernando

Posted on

Ibuprofeno.py💊| #145: Explica este código Python

Explica este código Python

Dificultad: Fácil

def resta(a,b):
    return a - b

resultado = resta(7, resta(4,2))
print(resultado)
Enter fullscreen mode Exit fullscreen mode
  • A. 1
  • B. 2
  • C. 3
  • D. 5

Respuesta:

👉 D. 5

En Python es posible usar como parámetro la llamada a otra función, siempre y cuando esta regrese algo.

En nuestro ejemplo la función resta siempre regresa la resta de dos números que recibe como parámetro, entonces al momento de llamar la función podemos hacer que un argumento sea la llamada a la misma función, en este caso con los parámetros 4 y 2.

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay