Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 18 Online
OpenStudy (anonymous):

#Mooc question In exercise 1.4, MIT6_189IAP11_hw1.pdf, how do I code for a 4th root in python. The problem that I am struggling with is finding the 4th root of -19+100. I know the answer but I don't know how to code it. I used the math.sqrt for one of the earlier problems.

OpenStudy (anonymous):

I had the same question http://openstudy.com/study?login#/updates/507db758e4b0eba0db5e9c9e Best way is use ** operator with 1/4

OpenStudy (anonymous):

Thank you. That works

OpenStudy (anonymous):

I did X**.25

OpenStudy (anonymous):

I puzzled over this wondering if Python had some special way to solve it. I then remembered that a root is the same as the exponential of the reciprocal so x = y**(1/4) Is there a more Pythonesque way to write this?

OpenStudy (anonymous):

Oh. that should have been x = y**(1.0/4)

OpenStudy (velumani):

a longer coding way would be to "import" math module and use math.sqrt function twice, like, math.sqrt(math.sqrt(x)) !!

OpenStudy (anonymous):

Is there a way if you import the math module to make an n-root instead of using two square roots in a row ?

OpenStudy (velumani):

@Kyol: When i looked for function that could do the nth root in the math module, i found none. But, there is the power function [pow()], the same as what @peterdb has stated above (which is simple and better). Then why import math function ...??!!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Mari103: How to pop out like a Jacc In the box
39 minutes ago 0 Replies 0 Medals
Breathless: Spooky witch but cute
7 hours ago 3 Replies 0 Medals
Arriyanalol: help
7 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
10 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
10 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!