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`

Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Digital activation code. We're sorry, your donation failed to process. Free 2025 jamb questions and answer /2025 jamb cbt questions & answers |free jamb 2025 answers.