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
- Unarchived Memories December 17, 2025
- Fixing CloudFront HTTP/2 Configuration December 15, 2025
- Packets to a Silent Modem December 14, 2025