OPP644-“Datatype Conversion”

Converting one datatype to another is called datatype conversion. Below are the details of the same >>> t="dd" >>> type(t) <type 'str'> >>> int(t)    Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> int(t) ValueError: invalid literal for int() with base 10: 'dd' >>> t="78" >>> type(t) <type 'str'> >>> d=int(t) >>> type(d) <type 'int'> >>> t '78' >>> int(t) 78 >>> float(t) 78.0 >>> complex(t) (78+0j) >>> repr(t)       #... Continue Reading →

Powered by WordPress.com.

Up ↑

%d bloggers like this: