1 - Idiomatic Python
Published online by Cambridge University Press: 30 August 2023
Summary
After a discussion of best programming practices and a brief summary of basic features of the Python programming language, chapter 1 discusses several modern idioms. These include the use of list comprehensions, dictionaries, the for-else idiom, as well as other ways to iterate Pythonically. Throughout, the focus is on programming in a way which feels natural, i.e., working with the language (as opposed to working against the language). The chapter also includes basic information on how to make figures using Matplotlib, as well as advice on how to effectively use the NumPy library, with an emphasis on slicing, vectorization, and broadcasting. The chapter is rounded out by a physics project, which studies the visualization of electric fields, and a problem set.
- Type
- Chapter
- Information
- Numerical Methods in Physics with Python , pp. 1 - 30Publisher: Cambridge University PressPrint publication year: 2023