Number type conversion

In some situations, you need to convert a number explicitly from one type to another to satisfy some requirements. Python does this internally in an expression

  • Type int(a) to convert a into an integer
  • Type float(a) to convert a into a floating-point number
  • Type complex(a) to convert a into a complex number with real part x and imaginary part zero
  • Type complex(a, b) to convert a and b into a complex number with real part a and imaginary part b. a and b are numeric expressions
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset