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
- Entropy November 13, 2025
- The Unquiet Past November 12, 2025
- King Sorrow October 22, 2025