DEV Community

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

Posted on

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

Explica este código Python

Dificultad: Fácil

a = 18.5
b = int(a)
print(float(b))
Enter fullscreen mode Exit fullscreen mode
  • A. 18
  • B. 18.0
  • C. 19.0
  • D. 19

Respuesta:

👉 B. 18.0

18.5 a entero seria 18 puesto que solo tomamos la parte entera.
18 a float seria 18.0 porque completamos con .0 un número que ya era entero.

Top comments (1)

Collapse
 
mauro_peluso_22 profile image
Mauro Peluso • Edited

B? :{D

al tener el float 18.5 y convertirlo en "b" un int pasa a ser solo 18
cuando imprimes "b" en un nuevo float sería 18.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