My assignment in python programming ask me to arrive at the solution of a program where we can find the power numbers.
For eg. 2^4 = 16 Is it possible to get this solution directly without using the actual logic in programming?
My assignment in python programming ask me to arrive at the solution of a program where we can find the power numbers.
For eg. 2^4 = 16 Is it possible to get this solution directly without using the actual logic in programming?
I'm not sure I have got a well understanding of your question. I'm going to assume that you are asking how to get for instance 2 to the power of 4 (i.e. 2^4).
In python, the power operator is actually predifined as **
. So 2^4
is written 2 ** 4
.
I expect I have answered your question.
In addition ...
The **
operator is more CPU consuming so if you want for instance to rise a number to the power of 2, prefer using number * number
instead of number ** 2
.
you can use ** directly. (i.e) 2 ** 4. In python x^y is written as x ** y. Hope it will be helpful for your project.
In python, an exponent operator is **
.
When you write 2**4
, it means 2^4
in mathematical language.