Since adding up the numbers is the purpose of the program, we will dive into that section first. One of the benefits of literate programming is that you can go in any order you please. Therefore, you can explain the most important concepts first, even if they appear later in the source file.
The code in this section will generate a range from 1 to number + 1, and then iterate through and add them all to the variable total.
Add up numbers from one to the number given = for num in range(1, number + 1): total = total + num
Initialize variables = total = 0