Finding the square root in python with the ** operator

2.3k views Asked by At

I am slightly confused on what the ** operator means in python

import math 
radius = raw_input("Enter your radius")
area_of_circle = radius ** math.pi
print area_of_circle

What I am trying to do is figure out what the ** operator would do. This is for a problem on Codeacademy, which involves finding the square root. Plese do not give me the answer just suggestions on a syntax to get the square root.

3

There are 3 answers

0
litaoshen On

you can just run it and you will find that x*y means x to the power of y like 2**3=8

0
Steve Jessop On

** is the exponentiation operator.

Since you only want hints: if you know a number for which raising x to the power of that number is the same as taking a square root, then you can compute the square root of x using x ** that_number.

By the way, you don't need to compute a square root in order to determine the area of a circle from its radius.

0
Cryonix On

x ** 0.5 = sqrt(x) could be possible?