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)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more