loop

Marko Rauhamaa marko at pacujo.net
Mon Mar 24 11:04:32 CET 2014


Mark Lawrence <breamoreboy at yahoo.co.uk>:

> On 24/03/2014 07:47, Marko Rauhamaa wrote:
>>      for i in [ 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 ]:
>
> Why the overhead of creating a list when you could use a tuple? :)

Once in college, we were given assembly programming assignments. The
textbook defined an imagined 18-bit CPU and an instruction set.

A fellow student was given the task to write a subroutine that
calculates the factorial of the argument. He went through the trouble of
creating a loop with multiplication etc. I argued (in vain) that his
solution is "wrong" from all angles; he should have implemented his
subroutine with a simple lookup table since 18 bits can only take a
handful of input values (0 through 8).


Marko



More information about the Python-list mailing list