[Tutor] Calculate 4**9 without using **, was Re: QUESTION

Peter Otten __peter__ at web.de
Sat Mar 4 05:43:46 EST 2017


D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote:
> On Sat, Mar 4, 2017 at 2:20 PM, Peter Otten <__peter__ at web.de> wrote:

>> "what is another way I can do 4**9 without using **?"
>>
>> sounds a lot like a homework question -- so you really have to think
>> about it yourself a bit. A few hints:
>>
>> How would you do the calculation with pen and paper?
>>
>> Can you translate that into a Python loop? What kind of loop would you
>> choose to repeat something 9 times?

> Much simpler is
> 
> 4*4*4*4*4*4*4*4*4

The idea behind the approach I suggested is to lead towards some level of 
abstraction. The for-loop can be put into a function, the exponent be given 
by the user at runtime etc...



More information about the Tutor mailing list