[Tutor] Cube root

akleider at sonic.net akleider at sonic.net
Sun Sep 16 03:40:35 CEST 2012


> On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel <d at davea.name> wrote:
>> On 09/15/2012 05:28 PM, Amanda Colley wrote:
>>> Ok, I have to get input from a user  ('enter a number') and then get
>>> the
>>> cube root of that number.  I am having trouble with the code to get the
>>> cube root. If anyone can help me solve this I would greatly appreciate
>>> it.
>>> ('enter a number')
>>> n=number
>>> ???  cube root??
>>>
>>>
>>
>> The operator to raise a number to a particular power is **, and it's not
>> constrained to integer powers.  So 5*2 is 25.  See what's next?
>>
> This is a great place to ask questions.  But don't forget google (or bing)
>
> try googling python cube root
>
> see how you do and come back with your code!
> --
> Joel Goldstick

OOPS!!
Should have been:
>>> 27.0**(1.0/3.0)
3.0
>>>
Which works better than expected!





More information about the Tutor mailing list