DEV Community

Cover image for Ibuprofeno.py💊| #164: Explica este código Python
Cristian Fernando
Cristian Fernando

Posted on

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

Explica este código Python

Dificultad: Fácil

def myfunc(a):
    a = a + 2
    a = a * 2
    return a
print(myfunc(2))
Enter fullscreen mode Exit fullscreen mode
  • A. 8
  • B. 16
  • C. Indentation Error
  • D. Runtime Error

Respuesta:

👉 A. 8

Llamamos a función con el valor de 2 por ende la primera asignación que tenemos es a = a + 2 donde a=4.

Para la segunda asignación ya sabemos que a=4 entonces a = a * 2 será 4*2 asignando y sobre escribiendo el valor de la variable para que tengamos a=8.

Finalmente regresamos a=8.

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

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay