+ 1
How to convert data type explicitly
as in c++ we can simply write ( float)
5 Answers
+ 2
I'm newcomer to python.
Don't know if my answer will help you.
There are some laws i summed up early.
print (int(99.9))
print (int('123'))
print (int(-99.11))
print (float(85))
print (str(123))
print (str(11.2))
#But you cannot convert an int or float into string. Forgive my poor english. I'm a chinese.
+ 1
the operand with the ânarrowerâ type is widened to that of the other, where plain integer is narrower than long integer is narrower than floating point is narrower than complex. The constructors int(), long(), float(), andcomplex() can be used to produce numbers of a specific type.
for conversion to string use str(x) where x is any object or variable..
abs(x) absolute value or magnitude of x
int(x) x converted to integer
long(x) x converted to long integer
float(x) x converted to floating point
complex(re,im) a complex number with real part re, imaginary partim. im defaults to zero.
- 3
hooooooooaaaaaaaaooooooaaaaaaoooooooaaaaaoooooooaaallllllllllllllllllalallalalalalalalalalalalallalalaallalalaallalaallalallalalalalalaalalalallalalalalalalalalalalalalallalalalalalalaallalalalalalalalalalalalalalalallalalalalalalalalalalallalallalalalalalalalalalalalalaalalalalalalalaalalalalalalalaalallalalalalÂȘl
- 3
yo lo
- 4
lol