Adding
February 24, 2018
I wrote a simple script for adding that uses a function to hold two variables and then add them together. You create a function by using def and then giving it a name.
# -*- coding: utf-8 -*-
def add(value_1, value_2):
print "Adding %d and %d together." % (value_1, value_2)
return value_1 + value_2
cost = add(2345,1234)
print "The cost is: £{0:.2f}".format (cost)
Be sure to use the utf-8 value at the top or else Python will not understand the currency character.
Recent Entries
- Wonder 2 Finally Shows Some Restraint January 25, 2026
- Forty-Five Bugs Hiding in Plain Sight January 23, 2026
- Cleaning the Metadata January 21, 2026