-5

Is it possible to type a squared number in python? Or how to type for example 5 to the power of 2

Sammyng
  • 19
  • 3

1 Answers1

-1

number**power

As Joran Beasley said you only type **2 next to the number to take it to the power of 2.

In python we multiply with * so ** is multiplying two times, which is square. however *** is an error and **3 is cubic.

however you can also define a method

def power(number,n):
    x=1
    for n in range(n):
       x=number*x
    return x

print(power(5,8))