Lecture Notes on 11 Sep 2009 while (cond): # body of the loop # Example of an infinite loop while (True): # some statement # Example of a loop that never gets executed while (False): # some statement # Sum all the numbers from 1 to 100 sum = 0 count = 1 while (count <= 100): sum = sum + count count = count + 1 print "Sum = ", sum # Template for Day.py def main(): # Prompt the user to enter day day = input ("Enter day: ") print "Day = ", day # Check if the day is in the range 1 through 31 while ((day < 1) or (day > 31)): day = input ("Enter day: ") print "Day = ", day # Prompt the user to enter month month = input ("Enter month: ") print "Month = ", month # Prompt the user to enter year year = input ("Enter year: ") print "Year = ", year # Adjust month to start from March # Decrement year for January and February if ((month == 1) or (month == 2)): month = month + 10 year = year - 1 else: month = month - 2 main()