# 2 November

## Birthday program, using input and comparisons

``name_a = raw_input("Enter name of person 1: ")name_b = raw_input("Enter name of person 2: ")year_a = int(raw_input("Enter birth year of " + name_a + ": "))month_a = int(raw_input("Enter birth month of " + name_a + ": "))day_a = int(raw_input("Enter birth day of " + name_a + ": "))year_b = int(raw_input("Enter birth year of " + name_b + ": "))month_b = int(raw_input("Enter birth month of " + name_b + ": "))day_b = int(raw_input("Enter birth day of " + name_b + ": "))if year_a < year_b or (year_a == year_b and                       (month_a < month_b or (month_a == month_b and                                                 day_a < day_b))):    print name_a, "is older than", name_belse:    print name_b, "is older than", name_a``

## Guessing program, using random and a loop.

``# Guessing game# Chris Leagueimport randomsecret = random.randint(1,100)print "I have a secret number."guess = int(raw_input("Your guess: "))while guess != secret:       # not equal    distance = guess - secret    if distance < -15:        print "WOW that's WAY too low, man."    else:        if distance < 0:            print "Too low."        else:            if distance < 15:                print "Too high."            else:                print "OH MAN you are HIGH."    guess = int(raw_input("Your guess: "))print "You won!"``

©2011 Christopher League · some rights reserved · CC by-sa