+ 1

How to convert data type explicitly

as in c++ we can simply write ( float)

27th Jun 2016, 4:22 AM
Rituraj Mehra
Rituraj Mehra - avatar
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.
27th Jun 2016, 8:44 AM
çżŸć«ç« 
çżŸć«ç«  - avatar
+ 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.
8th Jul 2016, 12:55 PM
Subhankar Paul
Subhankar Paul - avatar
- 3
hooooooooaaaaaaaaooooooaaaaaaoooooooaaaaaoooooooaaallllllllllllllllllalallalalalalalalalalalalallalalaallalalaallalaallalallalalalalalaalalalallalalalalalalalalalalalalallalalalalalalaallalalalalalalalalalalalalalalallalalalalalalalalalalallalallalalalalalalalalalalalalaalalalalalalalaalalalalalalalaalallalalalalÂȘl
30th Jun 2016, 8:49 PM
Carlos Aarón Bernal Patiño
Carlos Aarón Bernal Patiño - avatar
- 3
yo lo
30th Jun 2016, 8:49 PM
Carlos Aarón Bernal Patiño
Carlos Aarón Bernal Patiño - avatar
- 4
lol
30th Jun 2016, 8:48 PM
Carlos Aarón Bernal Patiño
Carlos Aarón Bernal Patiño - avatar