为什么x = 7< 5; print(x)在python中给出假?

发布于 2025-01-21 19:56:45 字数 1488 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吃不饱 2025-01-28 19:56:45

您似乎已经混合了不平等运营商的方向。

当Python看到x = 7&lt时; 5,它找到了不等式的真实价值7< 5并将其分配给x。 7 不小于5,因此语句7< 5false。因此,python说x = false

x = 7&gt的反向是正确的。 5。 7 IS 大于5,所以7> 5truex = true

记住鳄鱼法:< and>就像一个饥饿的鳄鱼,寻找可以吃的食物最多的食物,因此它将指向较大的价值并远离较小的食物。

You seem to have mixed up the direction of the inequality operators.

When Python sees x = 7 < 5, it finds the truth value of the inequality 7 < 5 and assigns it to x. 7is not less than 5, so the statement 7 < 5 is False. So Python says x = False.

The reverse is true of x = 7 > 5. 7 is greater than 5, so 7 > 5 is True and x = True.

Remember the alligator method: < and > are like a hungry alligator looking for the most food it can eat, so it will point toward the larger value and away from the smaller.

超可爱的懒熊 2025-01-28 19:56:45

这不应该是真的。 7不小于5,因此评估为错误。

It should not be true. 7 is not less than 5, and therefore evaluates to False.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文