[Tutor] Calculate 4**9 without using **
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Mar 4 17:56:51 EST 2017
On 04/03/17 16:17, Sri Kavi wrote:
> I'm a beginner learning to program with Python. I'm trying to explain a
> solution in plain English. Please correct me if I'm wrong.
See the thread earlier today with the subject QUESTION for
more on this topic.
> Create a function that takes base and exponent as arguments.
>
> In the body of the function:
>
> set a result variable to the base.
> Use a for-loop with a range of 1 to the exponent.
> With each iteration, set the result to the product of result times base.
> After the loop, return the result.
Is there anything there that you don't know how to do?
If not have a go and if it does not work come back to us
with your code and any error messages.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list