Python(1) 整型与浮动型

整型与浮动型


整数/浮动数=浮点型
整数/整数 = 浮点型
例如:
>>> type(1/1)
<class 'float'>
>>> type(1/1.0)
<class 'float'>

整数*整数=整数
整数*浮点数 = 浮点数

<class 'float'>
>>> type(1*1)
<class 'int'>
>>> type(1*1.0)
<class 'float'>

整数+-整数=整数
整数+-浮点数 = 浮点数

>>> type(1+1)
<class 'int'>
>>> type(1+1.0)
<class 'float'>

>>> type(1-1)
<class 'int'>
>>> type(1-1.0)
<class 'float'>

原文地址:https://www.cnblogs.com/guangzhou11/p/11529347.html