The latest version of this document can be found at \kref{https://git.kjodle.net/kjodle/Notes-on-Python}{https://git.kjodle.net/kjodle/Notes-\\on-Python}.
To quote from the Python Software Foundation:\cite{pythonorg:blurb}
\begin{quote}
\textit{Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.}
I won't bore you with details. If you have made enough effort to find this document, you are probably aware of the importance of the Python programming language. If not, however, I'll give a brief summary.
Python is platform independent. It emphasizes a concise syntax that aids in code readability. It also supports multiple coding styles, such as functional, imperative, object-oriented, and procedural.
\paragraph{Functional} Every statement is a kind of math equation. Functional programming is good for use in parallel processing activities.
\paragraph{Imperative} Computations occur as changes to program state. This is most often used for manipulating data structures.
\paragraph{Object-Oriented} This programming style uses objects to model the real world. It isn't fully implemented in Python because Python doesn't support features like data hiding.
\paragraph{Procedural} Tasks proceed one step at a time. Most often used for iteration, sequencing, selection, and modularization. It is the simplest form of programming.
Many fields depend on \kpy\footnote{This is my attempt to produce a text symbol for Python, similar to \LaTeX{}. My thought is that it looks like a snake wriggling back and forth. Your mileage, of course, may (and probably will) vary. If you would like to use this in your own documents (why?) I have defined it as a macro, which you can obtain from the source code for this document. See the abstract for its location.} to process data.
Mueller\cite{mueller-jp:23} has many reasons why a knowledge of Python may be useful in a job search. \kpull{This is \textit{not} my favorite book.}{22mm} They were fairly accurate as of their publication (2023),but things change quickly, so a keyword search of your preferred job boards is always in order.
Python supports single line comments by adding a hashtag (\texttt{\#}) to the beginning of each line:
\begin{Verbatim}
# This line is a comment.
\end{Verbatim}
Mulitline comments are not directly supported by Python. However, you can surround groups of lines to be commented out by using three double quotations marks or three single quotations marks on the lines before and after them:
The main difference between single line comments and multiline comments is that single line comments do not get exported to reports, whereas multiline comments do. Again, this is because Python does not fully support multiline commenting.
\subsubsection{Uses of Comments}
Comments are highly useful when writing code and often underutilized or poorly utilized. It has been suggested\cite{denker-j} that
\begin{quote}
\rule{\linewidth}{0.5pt}
software = code + documentation
\vspace{-12pt}
\rule{\linewidth}{0.5pt}
\end{quote}
That documentation is both external (i.e., user manuals) and internal (i.e., comments). You can (and should) use comments to:
\begin{itemize}[noitemsep]
\item Remind yourself what the code does and why you wrote it.
\item Record who wrote the code in a multi-person project.
\item Tell others how to maintain the code.
\item Make your code accessible to other developers.
\item List ideas for future updates.
\item Document the sources you used to build the code.
\item Maintain a list of improvements you've made.
\end{itemize}
You can, of course, also use comments to prevent certain lines of code from executing, a practice known as ``commenting out''. This is useful when troubleshooting your code.
\kbib{}This book \textit{heavily} emphasizes the use of Google Colab. It's basically an advertisement for the $\Gamma$oogle and \textit{highly} disappointing. Python is meant to be fairly universal and this book's approach seems to work counter to that intention.