day1/exercise/arm.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Mon, 28 Jun 2010 00:14:02 -0500
branchscipy2010
changeset 426 7d8738ce004d
parent 425 5afcfce15e71
permissions -rw-r--r--
Adding an acknowledgement slide to session 1. Minor changes to session 2.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
cubes = []
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
for i in range(10):
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
    cubes.append(i ** 3)
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
for i in range(100, 1000):
425
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     6
    ones = i % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     7
    tens = (i / 10) % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     8
    hundreds = (i / 100) % 10
5afcfce15e71 REF: Reformat some of the exercises so they're easier to read for the audience.
Christopher Burns <chris.d.burns@gmail.com>
parents: 64
diff changeset
     9
    if i == cubes[ones] + cubes[tens] + cubes[hundreds]:
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
        print "Armstrong Number: ", i