You can convert numbers using the following functions:
int(): will result in an integer
float(): will result in floating-point numbers
complex(): will result in complex
Example 1:
x = 2.2
print(int(x))
Output:
2
Example 2:
x = 2
print(float(x))
Output:
2.0
Example 1:
x = 2
print(complex(x))
Output:
2+0j
-------------------------Subscribe----------------------------
• If you like to see a variety of fun and interactive projects written in Python
• If you love ☕ and 🐶 WAIT! - Yeah! Definitely, coffee and dogs!
-----------------------------------------------------------------------
-------------------------Socials----------------------------
• Twitter: / iftodd1
• Facebook: / iftodd
• Instagram: / if_todd
------------------------------------------------------------------
-------------------------Support----------------------------
You can support me here: / if_todd
--------------------------------------------------------------------
How to convert from one number type to another? #shorts #python #iftodd