# ###### 自动类型的转换 数字类型 Number(int float bool complex)
"""
精度从高到低 bool<int<float<complex
自动类型的转换,默认是从低精度向高精度进行转换
"""
# 1.bool + int
'''
True = 1
False = 0
'''
res = True + 100
print(res)
# 2. bool + float
"""
True = 1.0
False = 0.0
"""
res = True +3.5
print(res)
# 3. bool + complex
"""
True = 1 + 0j
False = 0j
"""
res = True + 3-90j
print(res)
# 4. int + float
'''
4 = 4.0
'''
res = 4 + 3.9
print(res)
# 5. int + complex
'''
5 = 5 + 0j
'''
res = 5 + 3-1j
print(res)
# 6. float + complex
'''
8.8 = 8.8 + 0j
'''
res = 8.8 + 3.1+1j
print(res)
# ######## 第二遍
# ###### 自动类型的转换 数字类型 Number(int float bool complex)
"""
精度从高到低 bool<int<float<complex
自动类型的转换,默认是从低精度向高精度进行转换
"""
# 1.bool + int
'''
True = 1
False = 0
'''
res = True + 100
print(res)
# 2. bool + float
"""
True = 1.0
False = 0.0
"""
res = True +3.5
print(res)
# 3. bool + complex
"""
True = 1 + 0j
False = 0j
"""
res = True + 3-90j
print(res)
# 4. int + float
'''
4 = 4.0
'''
res = 4 + 3.9
print(res)
# 5. int + complex
'''
5 = 5 + 0j
'''
res = 5 + 3-1j
print(res)
# 6. float + complex
'''
8.8 = 8.8 + 0j
'''
res = 8.8 + 3.1+1j
print(res)
第三天(数字类型的自动转换)
最新推荐文章于 2022-08-13 16:48:20 发布