### Python, The Lazy Mathematician’s Langauge

#### by jasonyeo

I was supposed to compute a exponentiation modulo 10 table for my networking homework. The question went like this:

Write a Exponentiation Modulo 10 table for 0 to 9. That is x = 0 to 9, y = 0 to 9 and the table values are x^y mod 10.

After computing the first few values, I got tired and fired up my python shell to get the computer to compute for me. This was my code:

>>> for x in range(10):

... print [x**y % 10 for y in range(10)]

This is the output:

[1, 0, 0, 0, 0, 0, 0, 0, 0, 0]

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

[1, 2, 4, 8, 6, 2, 4, 8, 6, 2]

[1, 3, 9, 7, 1, 3, 9, 7, 1, 3]

[1, 4, 6, 4, 6, 4, 6, 4, 6, 4]

[1, 5, 5, 5, 5, 5, 5, 5, 5, 5]

[1, 6, 6, 6, 6, 6, 6, 6, 6, 6]

[1, 7, 9, 3, 1, 7, 9, 3, 1, 7]

[1, 8, 4, 2, 6, 8, 4, 2, 6, 8]

[1, 9, 1, 9, 1, 9, 1, 9, 1, 9]

Not bad huh. I am pretty impressed that python can do it in just two lines of code.