Python 和 Powers Math [英] Python and Powers Math

查看:15
本文介绍了Python 和 Powers Math的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习 Python,但我有点困惑.当我试图加注到某个数字时,在线教练告诉我使用运算符 ** 而不是 ^.示例:

I've been learning Python but I'm a little confused. Online instructors tell me to use the operator ** as opposed to ^ when I'm trying to raise to a certain number. Example:

print 8^3

给出 11 的输出.但我正在寻找的(我被告知)更类似于:print 8**3,它给出了 512 的正确答案.但为什么呢?

Gives an output of 11. But what I'm look for (I'm told) is more akin to: print 8**3 which gives the correct answer of 512. But why?

谁能给我解释一下?为什么 8^3 不等于 512,因为它是正确答案?在什么情况下会是 11(8^3 的结果)?

Can someone explain this to me? Why is it that 8^3 does not equal 512 as it is the correct answer? In what instance would 11 (the result of 8^3)?

我确实尝试过搜索 SO,但我只看到有关在除法时获取模数的信息.

I did try to search SO but I'm only seeing information concerning getting a modulus when dividing.

推荐答案

Operator ^ 是一个 按位运算符,它执行按位异或.

Operator ^ is a bitwise operator, which does bitwise exclusive or.

幂运算符**,比如 8**3 等于 512.

这篇关于Python 和 Powers Math的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆