[Tutor] Teaching Python
Peter Otten
__peter__ at web.de
Wed Jan 6 15:40:26 EST 2016
yehudak . wrote:
> My grandson Guy (8th grader) is learning Python at school. That's what
> made me teach myself Python programming as well.
> Yesterday he asked my help in his homework:
>
> Write a FOR-loop that prints all numbers up to 1000000
>
> Thank you, the gods of Ctrl+C
Did you mean to imply that it took too long?
It is likely that the terminal (emulation) is to blame, and not the python
interpreter:
$ time python3 -c 'for i in range(10**6): print(i)' > /dev/null
real 0m1.562s
user 0m1.525s
sys 0m0.033s
Under 2 seconds on quite old hardware. Without redirection in Konsole (KDE's
terminal emulator):
$ time python3 -c 'for i in range(10**6): print(i)'
[...]
999997
999998
999999
real 0m16.167s
user 0m5.258s
sys 0m5.512s
But wait -- you ran the code in IDLE, right?
Then book it under lessons learned ;)
More information about the Tutor
mailing list