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
- Filter First, Think Later February 21, 2026
- Five Hundred Bugs That Fuzzers Missed February 20, 2026
- Gemini 3.1 Pro and the 0.1 That Matters February 19, 2026