Offering a new perspective, this textbook demystifies the operation of electric machines by providing an integrated understanding of electromagnetic fields, electric circuits, numerical analysis, and computer programming. It presents fundamental concepts in a rigorous manner, emphasising underlying physical modelling assumptions and limitations, and provides detailed explanations of how to implement the finite element method to explore these concepts using Python. It includes explanations of the conversion of concepts into algorithms, and algorithms into code, and examples building in complexity, from simple linear-motion electromagnets to rotating machines. Over 100 theoretical and computational end-of-chapter exercises test understanding, with solutions for instructors and downloadable Python code available online. Ideal for graduates and senior undergraduates studying electric machines, electric machine design and control, and power electronic converters and power systems engineering, this textbook is also a solid reference for engineers interested in understanding, analysing and designing electric motors, generators, and transformers.