-3

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?

  • 2
    ```2**4```. What about ```**```. And what is *actual logic in programming?* –  Jun 25 '21 at 10:14
  • This thing should be marked as duplicate anyway just look [here](https://stackoverflow.com/questions/12043913/python-and-powers-math) – Jakub Dóka Jun 25 '21 at 10:23

3 Answers3

1

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.

Atepir
  • 29
  • 2
1

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.

Gokulraaj
  • 26
  • 2
0

In python, an exponent operator is **.

When you write 2**4, it means 2^4 in mathematical language.