python double asterik **

Posted on Updated on

I was wondering what the ** in a piece of code was doing

found that it is to the power of


print 2*3 would be 6


print 2**3 would be 8 (two to the power of three  ie: 2^3)


“The caret operator ^ is typically used for a binary XOR operation in languages like C, C++, Java, and so on. It makes sense that Python didn’t want to “go against the flow” of what existing languages already use.”

-empire359 on reddit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s