9. The automatic conversion

# ### automatic type conversion (Number Type directed to) a float int BOOL Complex 
'' ' 
time when different data types Number of calculation, the more accurate the default conversion 
accuracy from low to high order: 
    BOOL -> int -> a float -> Complex 
    True default conversion is. 1 
    False default conversion is 0 
'' ' 
# (. 1) BOOL + int 
RES = True + 89 
Print (RES) 
 
# (2) BOOL + a float 
RES = True + 55.78 
Print (RES) 
 
# (. 3) + Complex BOOL 
RES = False + 2-4j 
Print (RES) 
 
# (. 4) + a float int 
RES = + 31 is 4.1 
Print (RES) 
 
# (. 5) int + Complex 
RES. 17 = + 4-7j 
Print (RES ) 
 
# (. 6) a float + Complex 
RES. 3 = 8.12 + +. 5J 
Print (RES)

  

Guess you like

Origin www.cnblogs.com/eliwen/p/10967673.html