This textbook introduces step by step the basic numerical methods to solve the equations governing the motion of the atmosphere and ocean, and describes how to develop a set of corresponding instructions for the computer as part of a code. Today's computers are powerful enough to allow 7-day forecasts within hours, and modern teaching of the subject requires a combination of theoretical and computational approaches. The presentation is aimed at beginning graduate students intending to become forecasters or researchers, that is, users of existing models or model developers. However, model developers must be well versed in the underlying physics as well as in numerical methods. Thus, while some of the topics discussed in the modeling of the atmosphere and ocean are more advanced, the book ensures that the gap between those scientists who analyze results from model simulations and observations and those who work with the inner works of the model does not widen further. In this spirit, the course presents methods whereby important balance equations in oceanography and meteorology, namely the advection-diffusion equation and the shallow water equations on a rotating Earth, can be solved by numerical means with little prior knowledge. The numerical focus is on the finite-difference (FD) methods, and although more powerful methods exist, the simplicity of FD makes it ideal as a pedagogical introduction to the subject. The book also includes suitable exercises and computer problems.