Lecture Notes on 25 Sep 2009 # This program prompts the user to enter his birthday and # it returns the lucky number for the user # This function adds the digits of a given number def sumDigits (n): sum = 0 while (n >0): sum = sum + (n % 10) n = n / 10 return sum def main(): day = input ("Enter birth day: ") month = input ("Enter birth month: ") year = input ("Enter birth year: ") sum = day + month + year while (sum >= 10): sum = sumDigits (sum) print "Your Lucky Number is:", sum main() # This program prompts the user for an upper limit and # it returns all the prime numbers below it # This function determines if a given number is prime or not def isPrime (n): limit = int (n**0.5) count = 2 while (count <= limit): if (n % count == 0): return False count = count + 1 return True def main(): count = 2 limit = input ("Enter upper limit: ") while (count <= limit): if (isPrime(count)): print count count = count + 1 main()