Tuesday, July 8, 2014

Day 94

Python at CodeCademy. Worked on Python tutorial 1 of 19, Functions, What Good are Functions? Checked out the code in the editor. Saw how much of the code I understand at first glance.

The code used:
def tax(bill):
    """Adds 8% tax to a restaurant bill."""
    bill *= 1.08
    print "With tax: %f" % bill
    return bill

def tip(bill):
    """Adds 15% tip to a restaurant bill."""
    bill *= 1.15
    print "With tip: %f" % bill
    return bill
meal_cost = 100
meal_with_tax = tax(meal_cost)
meal_with_tip = tip(meal_with_tax)

The interaction for this code looked like this:
With tax: 108.000000
With tip: 124.200000

No comments:

Post a Comment