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
Boards that focus on remote it jobs and freelance writing opportunities. The 10 best cary food delivery of 2024 | restaurants near me. Frequently asked questions get a host.