• Coding
  • Some built-in and extra python functions' definition.

Hey,
I thought we should have a post for that purpose (using python 2.7.3)
I will begin with some and you're welcomed to add yours, please adopt the following form:
def sum(list): #Built in function
    return reduce(lambda x, y: x+y, list)
def factorial(n): #Built in function
    return reduce(lambda x, y: x*y, xrange(1,n+1)
def product(list): #Not built in
    return reduce(lambda x, y; x*y, list)
def pow(i, j):
    return i**j
def sin(a): # built in
    pi = 3.14159265
    x = (a*pi)/180 # x=a(in radians)
    return x-((x**3)/factorial(3))+((x**5)/factorial(5))-((x**7)/factorial(7))
def cos(a):#built in
    return 1-(sin(a)**2) # Fundamental relation of trigonometry,note: I already defined sin(a), i won't redefine it to compute cos(a)
def tan(a):#built in
    return sin(a)/cos(a) # As i said above I already defined sin(a) and cos(a), tan(a) should be able to use those functions
That's enough for today, i'm sure most of you guys know them but please try to show some appreciation.
Thanks, out.
What's the point of this thread, if not replicating the otherwise excellent Python documentation?

A small thing though: you don't need to use lambdas for your sum and product functions. Python has a builtin operator module that takes care of this perfectly (also it's a terrible idea to name your argument list):
import operator

def sum(sequence):
    return reduce (operator.add, sequence)

def product(sequence):
    return reduce(operator.mul, sequence)