0
4**(1/2) = 1

It's giving 1, it is suppose to be 2. If i replace the 1/2 with 0.5 it would work

power2
  • 929
  • 1
  • 8
  • 16

3 Answers3

1

1/2 gives integer result of 0, So 4**0 = 1

try 1.0/2

>>> 4**(1/2)
1
>>> 1/2
0
>>> 4**(1.0/2)
2.0
akalikin
  • 1,071
  • 12
  • 35
1

1 and 2 are integers, so 1/2=0 Hence you have 4**0 which is indeed 1. I don't know python at all, but from knowledge of other languages I suspect you need something like 1.0/2.0 to get 0.5

Ian Bush
  • 6,996
  • 1
  • 21
  • 27
0

1/2 is evaluated as an integral, so it gives 0. 0.5 is a float, so that works. What you want to do is add a dot either the one or the 2

1./2 = 0.5
MartyB
  • 135
  • 6