DEV Community

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

Posted on • Edited on

1

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

Explica este código Python

Dificultad: Fácil

var = 1
print(bool(var) + float("1"))
Enter fullscreen mode Exit fullscreen mode

👉 A. True1
👉 B. 11
👉 C. 2
👉 D. 2.0


Respuesta:

👉 D. 2.0

Vamos parte por parte:

  • var vale 1.
  • Tendríamos bool(1) que es igual a True por conversión de tipos (en Python 0 equivale a False y 1 equivale a True).
  • Luego float("1") convierte a la cadena "1" en un número con punto decimal, entonces nos daría 1.0.
  • Nos quedaría: True +1.0, recordemos queTrueequivale a1. Entonces tendríamos:1 + 1.0, el resultado final2.0`

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