Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Is ** In Python?

Tags:

python

I read the following python code:

 a=2**b

I know several languages like c,c++,c#,java... i even googled ** operator without any results.

so what does 2**b means?

like image 891
JIZZ Jid Avatar asked Oct 17 '11 12:10

JIZZ Jid


2 Answers

It is the exponentiation operator. In your example, a will have the result of 2 to the bth power.

Check out the last entry in the table in this section.

like image 181
Nate Avatar answered Oct 02 '22 09:10

Nate


it's simple ** means power, so 2**b means 2 to the power of b

like image 29
Martin Kristiansen Avatar answered Oct 02 '22 10:10

Martin Kristiansen