Python Functions

Functions

Using Functions

Defining Functions

Default Argument Values

Flexible Arguments

Anonymous Functions

Function Documentation

def pressure(v, t, n):
    """Compute the pressure in pascals of
    an ideal gas

    v -- volume of gas, in cubic meters
    t -- absolute temperature in degrees kelvin
    n -- particles of gas
    """
    k = 1.38e-23 # Boltzmann's constant
    return n * k * t / v