Homework 1
22C:80 Programming for Informatics
Due Monday, January 26, 2009
5 points

1. Write and test a Python program that has at least five lines of code.

Experiment a little! Make your own program. Certainly, you should look in the textbook, and you can also look on the web for examples, but your final result should be your own little program.

A program such as this would be suitable:

  def printNameAndAge(name, ageInYears):

    # we won't worry about leap years in this program
    ageInDays = ageInYears * 365  

    ageInHours = ageInDays * 24
    ageInMinutes = ageInHours * 60  
    ageInSeconds = ageInMinutes * 60  
    result = name
    
    print (name + " is:")    
    print ("   " + str(ageInYears) + " years old,")
    print ("   " + str(ageInDays) + " days old,")
    print ("   " + str(ageInMinutes) + " minutes old, and")
    print ("   " + str(ageInSeconds) + " seconds old.")