𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Introduction to Python for Science and Engineering, 2nd Edition

✍ Scribed by David J. Pine


Publisher
CRC Press
Year
2024
Tongue
English
Leaves
444
Series
Series of computational biophysics
Edition
2
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Introduction to Python for Science and Engineering offers a quick and incisive introduction to the Python programming language for use in any science or engineering discipline. The approach is pedagogical and β€œbottom up,” which means starting with examples and extracting more general principles from that experience. No prior programming experience is assumed.

Readers will learn the basics of Python syntax, data structures, input and output, conditionals and loops, user-defined functions, plotting, animation, and visualization. They will also learn how to use Python for numerical analysis, including curve fitting, random numbers, linear algebra, solutions to nonlinear equations, numerical integration, solutions to differential equations, and fast Fourier transforms.

Readers learn how to interact and program with Python using JupyterLab and Spyder, two simple and widely used integrated development environments.

All the major Python libraries for science and engineering are covered, including NumPy, SciPy, Matplotlib, and Pandas. Other packages are also introduced, including Numba, which can render Python numerical calculations as fast as compiled computer languages such as C but without their complex overhead.

✦ Table of Contents


Cover
Half Title
Series Page
Title Page
Copyright Page
Dedication
Contents
Preface to First Edition
Preface to Second Edition
About the Author
CHAPTER 1: Introduction
1.1. INTRODUCTION TO PYTHON FOR SCIENCE AND ENGINEERING
1.2. INSTALLING PYTHON
CHAPTER 2: Launching Python
2.1. INTERACTING WITH PYTHON: THE IPYTHON SHELL
2.2. THE IPYTHON SHELL
2.3. INTERACTIVE PYTHON AS A CALCULATOR
2.3.1. Binary Arithmetic Operations in Python
2.3.2. Types of Numbers
2.3.3. Numbers as Objects
2.4. VARIABLES AND ASSIGNMENT
2.4.1. Names and the Assignment Operator
2.4.2. Legal and Recommended Variable Names
2.4.3. Reserved Words in Python
2.5. SCRIPT FILES AND PROGRAMS
2.5.1. Editors for Python Scripts
2.5.2. First Scripting Example
2.6. PYTHON MODULES
2.6.1. Python Modules and Functions: A First Look
2.6.2. Some NumPy Functions
2.6.3. Scripting Example 2
2.6.4. Different Ways of Importing Modules
2.7. GETTING HELP: DOCUMENTATION IN IPYTHON
2.8. PERFORMING SYSTEM TASKS WITH IPYTHON
2.8.1. Magic Commands
2.8.2. Tab Completion
2.8.3. Recap of Commands
2.9. PROGRAMMING ERRORS
2.9.1. Error Checking
2.10. EXERCISES
CHAPTER 3: Integrated Development Environments
3.1. PROGRAMMING AND INTERACTING WITH PYTHON
3.2. PROGRAMMING STYLE AND CODING ERRORS: PEP 8 AND LINTERS
3.3. THE SPYDER IDE
3.3.1. Autoformatting and Linting in Spyder
3.3.2. Running Python Code in Spyder
3.4. THE JUPYTERLAB IDE
3.4.1. Jupyter Extensions
3.5. JUPYTER NOTEBOOKS
3.6. LAUNCHING A JUPYTER NOTEBOOK
3.7. RUNNING PROGRAMS IN A JUPYTER NOTEBOOK
3.8. ANNOTATING A JUPYTER NOTEBOOK
3.8.1. Adding Headings and Text
3.8.2. Saving a Jupyter Notebook
3.8.3. Editing and Rerunning a Notebook
3.8.4. Quitting a Jupyter Notebook
3.8.5. Working with an Existing Jupyter Notebook
CHAPTER 4: Strings, Lists, Arrays, and Dictionaries
4.1. STRINGS
4.1.1. Unicode Characters
4.2. LISTS
4.2.1. Slicing Lists
4.2.2. Multidimensional Lists
4.2.3. Appending to Lists
4.2.4. Tuples
4.3. DICTIONARIES
4.4. NUMPY ARRAYS
4.4.1. Creating Arrays (1-d)
4.4.2. Mathematical Operations with Arrays
4.4.3. Slicing and Addressing Arrays
4.4.4. Fancy Indexing: Boolean Indexing
4.4.5. Multidimensional Arrays and Matrices
4.4.6. Broadcasting
4.4.7. Differences Between Lists and Arrays
4.5. OBJECTS
4.6. EXERCISES
CHAPTER 5: Input and Output
5.1. KEYBOARD INPUT
5.2. SCREEN OUTPUT
5.2.1. Formatting Output with str.format()
5.2.2. Formatting with f-strings
5.2.3. Printing Arrays
5.3. FILE INPUT
5.3.1. Reading Data from a Text File
5.3.2. Reading Data from an Excel File: CSV Files
5.4. FILE OUTPUT
5.4.1. Writing Data to a Text File
5.4.2. Writing Data to a CSV File
5.5. EXERCISES
CHAPTER 6: Conditionals and Loops
6.1. CONDITIONALS
6.1.1. if, elif, and else Statements
6.1.2. More about Boolean Variables, Operators, and Expressions
6.2. LOOPS
6.2.1. while Loops
6.2.2. for Loops
6.2.3. Loop Control Statements
6.2.4. Loops and Array Operations
6.3. LIST COMPREHENSIONS
6.4. HANDLING EXCEPTIONS
6.5. EXERCISES
CHAPTER 7: Functions
7.1. USER-DEFINED FUNCTIONS
7.1.1. Looping Over Arrays in User-Defined Functions
7.1.2. Fast Array Processing for User-Defined Functions
7.1.3. Functions with More than One Input or Output
7.1.4. Type Hints
7.1.5. Positional and Keyword Arguments
7.1.6. Variable Number of Arguments
7.1.7. Passing a Function Name and Its Parameters as Arguments
7.2. NAMESPACE AND SCOPE IN PYTHON
7.2.1. Scope: Four Levels of Namespaces in Python
7.2.2. Variables and Arrays Created Entirely Within a Function
7.2.3. Passing Lists and Arrays to Functions: Mutable and Immutable Objects
7.3. ANONYMOUS FUNCTIONS: LAMBDA EXPRESSIONS
7.4. NUMPY OBJECT ATTRIBUTES: METHODS AND INSTANCE VARIABLES
7.5. EXAMPLE: LINEAR LEAST SQUARES FITTING
7.5.1. Linear Regression
7.5.2. Linear Regression with Weighting: Γ·2
7.6. EXERCISES
CHAPTER 8: Plotting
8.1. AN INTERACTIVE SESSION WITH PYPLOT
8.2. BASIC PLOTTING
8.2.1. Specifying Line and Symbol Types and Colors
8.2.2. Error Bars
8.2.3. Setting Plotting Limits and Excluding Data
8.2.4. Subplots
8.3. LOGARITHMIC PLOTS
8.3.1. Semi-Log Plots
8.3.2. Log-Log Plots
8.4. MORE ADVANCED GRAPHICAL OUTPUT
8.4.1. An Alternative Syntax for a Grid of Plots
8.5. PLOTS WITH MULTIPLE AXES
8.5.1. Plotting Quantities that Share One Axis but not the Other
8.5.2. Two Separate Scales for a Data Set
8.6. PLOTS WITH INSETS
8.7. MATHEMATICS AND GREEK SYMBOLS
8.7.1. Manual Axis Labeling
8.8. THE STRUCTURE OF MATPLOTLIB: OOP AND ALL THAT
8.8.1. The Backend Layer
8.8.2. The Artist Layer
8.8.3. The PyPlot (scripting) Layer
8.9. CONTOUR AND VECTOR FIELD PLOTS
8.9.1. Making a 2D Grid of Points
8.9.2. Contour Plots
8.9.3. Streamline Plots
8.9.4. Vector Field (quiver) Plots
8.10. THREE-DIMENSIONAL PLOTS
8.10.1. Cartesian Coordinates
8.10.2. Polar Coordinates
8.11. EXERCISES
CHAPTER 9: Numerical Routines: SciPy and NumPy
9.1. SPECIAL FUNCTIONS
9.1.1. Important Note on Importing SciPy Subpackages
9.2. SPLINE FITTING, SMOOTHING, AND INTERPOLATION
9.2.1. Interpolating Splines
9.2.2. Smoothing Splines
9.2.3. Finding Roots (zero crossings) of Numerical Data
9.3. CURVE FITTING
9.3.1. Linear Fitting Functions
9.3.2. Polynomial Fitting Functions
9.3.3. Nonlinear Fitting Functions
9.4. RANDOM NUMBERS
9.4.1. Initializing NumPy’s Random Number Generator
9.4.2. Uniformly Distributed Random Numbers
9.4.3. Normally Distributed Random Numbers
9.4.4. Random Distribution of Integers
9.4.5. Poisson Distribution of Random Integers
9.5. LINEAR ALGEBRA
9.5.1. Basic Computations in Linear Algebra
9.5.2. Solving Systems of Linear Equations
9.5.3. Eigenvalue Problems
9.6. SOLVING NONLINEAR EQUATIONS
9.6.1. Single Equations of a Single Variable
9.6.2. Solving Systems of Nonlinear Equations
9.7. NUMERICAL INTEGRATION
9.7.1. Single Integrals of Functions
9.7.2. Double Integrals
9.7.3. Integrating Numerical Data
9.8. SOLVING ODES
9.8.1. A First-Order ODE
9.8.2. A Second-Order ODE
9.9. DISCRETE (FAST) FOURIER TRANSFORMS
9.9.1. Continuous and Discrete Fourier Transforms
9.9.2. The SciPy FFT Library
9.10. EXERCISES
CHAPTER 10: Python Classes: Encapsulation
10.1. A VERY SIMPLE CLASS
10.2. A BRIEF INTRODUCTION TO MODULES AND PACKAGES
10.2.1. Pythonpath
10.3. A CLASS FOR READING AND PROCESSING DATA
10.3.1. The Data
10.3.2. The Class
10.3.3. The Code
10.4. A CLASS OF RELATED FUNCTIONS
10.5. INHERITANCE
10.6. EXERCISES
CHAPTER 11: Data Manipulation and Analysis: Pandas
11.1. DATA STRUCTURES: SERIES AND DATAFRAME
11.1.1. Series
11.1.2. DataFrame
11.2. INDEXING DATAFRAMES
11.2.1. Pandas iloc Indexing
11.2.2. Pandas loc Indexing
11.3. READING DATA FROM FILES USING PANDAS
11.3.1. Reading from Excel Files Saved as CSV Files
11.3.2. Reading from an Excel File
11.3.3. Getting Data from the Web
11.4. EXTRACTING INFORMATION FROM A DATAFRAME
11.5. PLOTTING WITH PANDAS
11.6. GROUPING AND AGGREGATION
11.6.1. The groupby Method
11.6.2. Iterating Over Groups
11.6.3. Reformatting DataFrames
11.6.4. Custom Aggregation of DataFrames
11.7. EXERCISES
CHAPTER 12: Animation
12.1. ANIMATING A SEQUENCE OF IMAGES
12.1.1. Simple Image Sequence
12.1.2. Annotating and Embellishing Videos
12.2. ANIMATING FUNCTIONS
12.2.1. Animating for a Fixed Number of Frames
12.2.2. Animating until a Condition is Met
12.3. COMBINING VIDEOS WITH ANIMATED FUNCTIONS
12.3.1. Using a Single Animation Instance
12.3.2. Combining Multiple Animation Instances
12.4. EXERCISES
CHAPTER 13: Speeding Up Numerical Calculations
13.1. NUMBA’S BASIC FUNCTIONS
13.1.1. Faster Loops and NumPy Functions
13.1.2. Vectorizing Functions with Numba
13.1.3. Numba Signatures
13.2. SIMULATIONS
13.2.1. A Brownian Dynamics Simulation
13.2.2. Nondimensional Simulation Variables and Parameters
13.2.3. Simulation with the Numba Decorator
13.2.4. Performance and Saving/Reading Large Data Files
13.2.5. Isolating Numerical Code for Numba
13.3. USING NUMBA WITH CLASSES
13.4. OTHER FEATURES OF NUMBA
13.5. EXERCISES
Appendix A: Maintaining Your Python Installation
A.1. UPDATING PYTHON
A.2. TESTING YOUR PYTHON INSTALLATION
A.3. INSTALLING FFMPEG FOR SAVING ANIMATIONS
A.4. ADDING FOLDERS/DIRECTORIES TO YOUR PYTHON PATH
A.4.1. Spyder
A.4.2. macOS
A.4.3. Windows
A.4.4. Linux
Appendix B: Glossary
Appendix C: Python Resources
C.1. PYTHON PROGRAMS AND DATA FILES INTRODUCED IN THIS TEXT
C.2. WEB RESOURCES
C.3. BOOKS
Index


πŸ“œ SIMILAR VOLUMES


Introduction to Python for Science and E
✍ David J. Pine πŸ“‚ Library πŸ“… 2019 πŸ› CRC Press 🌐 English

Series in Computational Physics<br /><i>Steven A. Gottlieb and Rubin H. Landau, Series Editors</i><br /><br /><br /><br /><strong>Introduction to Python for Science and Engineering</strong><br /><br /><br /><br />This guide offers a quick and incisive introduction to Python programming for anyone. T

Introduction to Data Science: A Python A
✍ Laura Igual, Santi SeguΓ­ πŸ“‚ Library πŸ“… 2024 πŸ› Springer 🌐 English

This accessible and classroom-tested textbook/reference presents an introduction to the fundamentals of the interdisciplinary field of data science. The coverage spans key concepts from statistics, machine/deep learning and responsible data science, useful techniques for network analysis and natural

Python for Kids, 2nd Edition: A Playful
✍ Jason R. Briggs πŸ“‚ Library πŸ“… 2022 πŸ› No Starch Press 🌐 English

<span>The second edition of the best-selling </span><span>Python for Kids</span><span>β€”which brings you (and your parents) into the world of programmingβ€”has been completely updated to use the latest version of Python, along with tons of new projects!</span><span><br><br>Python is a powerful, express

Python for Kids, 2nd Edition: A Playful
✍ Jason R. Briggs πŸ“‚ Library πŸ“… 2022 πŸ› No Starch Press 🌐 English

<span>The second edition of the best-selling </span><span>Python for Kids</span><span>β€”which brings you (and your parents) into the world of programmingβ€”has been completely updated to use the latest version of Python, along with tons of new projects!</span><span><br><br>Python is a powerful, express