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

example:

print 2*3 would be 6

but

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

#pythonnoob

“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

Advertisement

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s