How do I get a whole number as a result for a cube root?

后端 未结 6 1868
梦谈多话
梦谈多话 2021-01-13 13:15

I am creating a problem which requires me to find the cube root of certain numbers, some of them have whole number roots, but a lot of them don\'t.

I have numbers li

6条回答
  •  一向
    一向 (楼主)
    2021-01-13 14:07

    It's quite simple. Cast the floating point to a string and the string to a float. Like this

    float(str(pow(125, (1./3))))

提交回复
热议问题