Using Pweave

Learn about Pweave and how to add Markdown to a Python program.

Pweave uses Markdown to provide basic formatting like bolding text, italicizing text, and providing different header sizes. Here is a rundown on Markdown:

Markdown Result
# Text Heading 1 (like a title font)
## Text Heading 2 (subtitle font)
### Text Heading 3
**Text** Text (bold)
*Text* Text (italics)

In Python, a line with formatting needs to first have the single-line comment character #, then a single quote ', then the Markdown formatting.

#' # This is equivalent to Heading 1 font
#' ## This is Heading 2
#' ### Heading 3
#' #### etc
#' **This is bold**
#' *This is italics*

There is also a marker #+echo=False to hide the printout of anything after that marker until the next section or end of file is reached. For example, if you wanted to hide the imports section:

#' ## Imports
#+echo=False
......
#' ## Calculations

Anything between the #+echo=False and #' ## Calculations would be hidden from the new version.

The Max Q program needs to be adjusted slightly to have all of the plotting at the end; as a result, the max values need to be broken out into different variables so that the last max value does not overwrite the others. The headers are also added before the imports, before the equations, before the calculation, and before the plotting.

Get hands-on with 1200+ tech skills courses.