Appendix D — Code topics
This appendix gathers together links to parts of the book that cover various code topics in Python:
- Comments: Note 2.2 and Note 7.2.
- Variables: Section 4.7.
- Types of values in Python: Section 7.3.
- Lists in Python: Section 7.3.2.
- Arrays: Section 7.3.1.
- array length: Section 6.5.
- Indexing into arrays with integers: Section 6.6.
- Selecting multiple elements from arrays with slicing: Section 10.2.
- Strings — values containing text: Section 7.4.
- Randomness from your computer: Section 2.2.
- Types of brackets in Python: Note 4.2.
- Squaring values and arrays: Section 16.7.1.
- Introducing functions: Section 5.7.
- Named arguments to functions: Section 5.8.
- Functions and methods: Note 5.1.
- Ranges (continuous sequences) of integers: Section 5.9.
range
in Python (compared tonp.arange
): Section 5.10.- Advanced ranges (for example, using floating point values), using
np.arange
: Note 21.7. - Repeating elements of an array with
np.repeat
: Section 7.6} - The absolute function (
np.abs
) to convert all values to positive: Note 16.3. for
loops: Section 6.6.2.if
statements: Section 8.10.- Python modules and submodules: Note 12.7.
- Finding number of repeats using
np.bincount
: Section 11.6 - Combining Boolean arrays with
&
: Section 10.6 range
in Pythonfor
loops: Section 6.6.3- Testing whether all elements of an array are the same using
np.all
: Note 13.5 - Plotting and histograms (and histogram bins and bin edges): Section 12.15.2.
- Shuffling arrays with
rnd.permuted
: Section 8.14. - Choosing values at random with
np.choice
: Section 5.11. - Counting
True
values withsum
: Section 5.14. - Making arrays by random resampling with
np.choice
: Section 5.12. - Underscores in Python integers: Note 21.5.
- Building strings with format-strings: Section 21.1.1.
- What is an operator?: Note 23.2.
- Logical operators — or, and: Section 23.1.
- Concatenating arrays: Section 12.15.1.
- The Comma-Separated-Values (CSV) file format for data tables: Section 16.1.1.
- Introducing the Pandas Python data science library: Section 16.1.2.