Math Functions 2
April 03, 2018
Some more math functions in Python. Make sure you use your # -*- coding: utf-8 -*-
or the formatting will not work correctly.
# -*- coding: utf-8 -*-
def add(a, b, c):
print "\nADDING %d + %d + %d" % (a, b, c)
return a + b + c
price = add(12, 12, 12);print "The price is £{0:.2f}\n".format (price)
def multiply(a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
multiply_price = multiply(10, 10);print "The price is £{0:.2f}\n".format (multiply_price)
def subtracting(a, b):
print "SUBTRACTING %d - %d" % (a, b)
return a - b
subtract_price = subtracting(100, 50);print "The price is £{0:.2f}\n".format (subtract_price)
def division(a, b):
print "DIVIDING %d / %d" % (a, b)
return a / b
division_price = division(90, 2);print "The price is £{0:.2f}\n".format (division_price)
Recent Entries
- The Rise of Agents in Agentic Coding: Transforming Software Development August 20, 2025
- Bleu de Chanel L'Exclusif August 19, 2025
- CSS Optimization August 19, 2025