Practice Problems
Exam 2
Csc 2010, Spring 2010
---------------------------------

1. Write the code for the following function:

  def largestOfThree(num1,num2,num3):
  # this function takes 3 numbers as input and returns the largest
  # of the three.

2. Write the code for the following function:

  def drawConcentricCircles(win,x,y,n,separation):
  # Give a canvas win, and center point (x,y), draw n concentric circles
  # with radius of the innermost circle = 10 pixels. the radius of each subsequent
  # circle is "separation" pixels more than the previous. Also, color each band 
  # alternatively with green and red with the outermost band green. 

3. Write code for the following function:

  def firstOfNextMonth(day,month,year):
  # This function takes as input day: 1-31, month 1-12, 
  # year: 4-digit number > 1900 and returns a list of 3 
  # numbers [d,m,y] that corresponds to the day, month and year for the
  # first of the next month. For example, if day=27, month=12, and year=2009 
  # the function should return [1,1,2010]

4. Write code for the following function:

  def addOneSecond(hour,minute,second,ampm):
  # This function takes as input hour: 1-12, minute: 0-59, second: 0-50, 
  # ampm: 'a' or 'p' and returns a list [h,m,s,ap] which corresponds to 
  # the time after adding 1 second to # the input time. For example, if 
  # hour=12, minute=53, second=59, ampm='a' then the output should be 
  # [12,54,0,'a']