Python#

Block Highlighting#

Language highlighting can be enabled with PyMdown and Pygments by adding a supported programming language name directly after the first ``` grouping in a Markdown code block:

# calculate factorial of n
def fact(n):

    # no work required
    if n == 1 or n == 0:
        return 1

    # minimum amount of work
    return n * fact(n - 1)


if __name__=="__main__":
    n = 5
    factorial = fact(n)
    print(f"{n}! = {factorial}")

Block Markdown#

```python
# calculate factorial of n
def fact(n):

    # no work required
    if n == 1 or n == 0:
        return 1

    # minimum amount of work
    return n * fact(n - 1)


if __name__=="__main__":
    n = 5
    factorial = fact(n)
    print(f"{n}! = {factorial}")

```

Script adapted from Palistha Singh's "How Does Recursion Work? Explained with Code Examples"

Inline Hilighting#

Inline highlighting can be added by prefixing the code snippet with three colons and the name of the supported programming language:

```:::LANGUAGE some code snippet```
or
`:::LANGUAGE some code snippet`

Example:

The print() function can be used to print content to STDOUT: print("Hello World").

Inline Markdown#

The `:::python print()` function can be used to print content to STDOUT:
```:::python print("Hello World")```.