Skip to content

Formatting Conventions

Formatting Conventions

This book and supporting materials use the following formatting conventions:

Web Address

Web address will be shown as:

https://github.com/professorkazarinoff/Problem-Solving-with-Python

Important terms and vocabulary

Important terms and vocabulary are shown in italic text


There is a difference between local variables and global variables in Python code.

File Names

File Names are shown in bold and italic text


After completing the code, save the file as hello.py in the current directory.

Module and Package Names

Module and Package names will be shown in bold text


NumPy and Matplotlib are two useful packages for problem solvers.

Inline code

Inline code, including variable names, is shown in monospace font


To compare a variable use var == 'string' and make sure to include ==, the double equals sign.

Separate code blocks

Separate code blocks appear in their own sections in monospaced font

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

Anaconda Prompt Commands

Commands typed into the Anaconda Prompt are shown in separate sections which contain the prompt symbol > before each line. Note the prompt > should not be typed. The prompt symbol is included to indicate Anaconda Prompt, not a character for the user to enter.

> conda create -n env python=3.7
> conda activate env

Terminal Commands

Commands typed into the MacOS or Linux terminal appear in separate sections which contain the dollar symbol $ before each line. Note the dollar symbol $ should not be typed. The dollar symbol is included to indicate a terminal prompt, not a character for the user to enter.

$ pip install pint
$ cd pint_srcipts

Python REPL Commands

Commands typed into the Python REPL (the Python Interpreter) appears in separate code sections, which contain the triple arrow prompt >>> . Note the triple arrow >>> prompt should not be typed. Triple arrows are included to indicate the Python REPL prompt, not a character for the user to enter. The output from the Python REPL is shown on a separate line below the command, without the >>> prompt.

>>> 2 + 2
4
>>> print('Problem Solving with Python')
Problem Solving with Python

Jupyter Notebook cells

Commands typed into Jupyter notebook cells appear with the label In [#]: to the left of the code section. The output from Jupyter notebook cells is shown below the input cell. Only code in the input cells needs to be typed. Output cell are be produced automatically by clicking the run button or typing [shift]+[Enter]

In [1]:
A = 2
B = 3
C = A + B
print(C)

5

Keystrokes and Buttons

Keystrokes directly entered by the keyboard or buttons that are indicated on programs or web pages are shown inside square brackets in [monospaced font].


In order to delete a line use the [Backspace] key. To exit the shell type [shift]+[c]