Explain the difference between Function and Stored procedure?

Stored Procedures are pre-compiled objects which execute the code when called for. While a Function is compiled and executed when it is called for.