Page 89 - Beginning Programming with Pyth - John Paul Mueller
P. 89
Creating the Application
You’ve actually created your first Anaconda application by using the steps in the “Creating a new notebook” section, earlier in this chapter. The print() method may not seem like much, but you use it quite often. However, the literate programming approach provided by Anaconda requires a little more knowledge than you currently have. The following sections don’t tell you everything about this approach, but they do help you gain an understanding of what literate programming can provide in the way of functionality. However, before you begin, make sure you have the BPPD_04_Sample.ipynb file open for use because you need it to explore Notebook.
Understanding cells
If Notebook were a standard IDE, you wouldn't have cells. What you’d have is a document containing a single, contiguous series of statements. To separate various coding elements, you need separate files. Cells are different because each cell is separate. Yes, the results of things you do in previous cells matter, but if a cell is meant to work alone, you can simply go to that cell and run it. To see how this works for yourself, type the following code into the next cell of the BPPD_04_Sample file:
myVar = 3 + 4
print(myVar)
Now click Run (the right-pointing arrow). The code executes, and you see the output, as shown in Figure 4-14. The output is 7, as expected. However, notice the In [1]: entry. This entry tells you that this is the first cell executed.