为什么在整数运算函数中我会得到一个浮点数据类型?

huangapple go评论57阅读模式
英文:

Why do I get a Float data type for an Integer arithmetic function?

问题

check = (3*3+3/3-3)
print(check)
print(type(check))

o/p

7.0
<class 'float'>

Logic or Fundamentals

英文:
check = (3*3+3/3-3)
print(check)
print(type(check))

o/p

7.0
&lt;class &#39;float&#39;&gt;

Logic or Fundamentals

答案1

得分: 0

/ 运算符是一个浮点除法运算符。它总是返回一个浮点数。

>>> 3/3
1.0
英文:

The / operator is a float division operator. It always returns a float.

&gt;&gt;&gt; 3/3
1.0

huangapple
  • 本文由 发表于 2023年2月18日 01:43:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75487616.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定