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
- Jurassic World Rebirth July 02, 2025
- Vintage Adverts July 02, 2025
- Ready Player One June 29, 2025