Page 56 - Beginning Programming with Pyth - John Paul Mueller
P. 56

This exercise shows you how things work within Python. Each command that you type performs some task, but only after you tell Python that the command is complete in some way. The print() command displays data onscreen. In this case, you supplied text to display. Notice that the output shown in Figure 3-2 comes immediately after the command because this is an interactive environment — one in which you see the result of any given command immediately after Python performs it. Later, as you start creating applications, you notice that sometimes a result doesn’t appear immediately because the application environment delays it. Even so, the command is executed by Python immediately after the application tells Python that the command is complete.
are
Functional: Every statement is a kind of math equation. This style lends itself well to use in parallel processing activities.
Imperative: Computations occur as changes to program state. This style is most used for manipulating data structures.
Object-oriented: This is the style commonly used with other languages to simplify the coding environment by using objects to model the real world. Python doesn’t fully implement this coding style because it doesn’t support features like data hiding, but you can still use this approach to a significant degree. You see this style used later in the book.
Procedural: All the code you’ve written so far (and much of the initial code in this book) is procedural, meaning that tasks proceed a step at a time. This style is most used for iteration, sequencing, selection, and modularization. It’s the simplest form of coding you can use.
Even though this book doesn’t cover all these coding styles (and others that Python supports),
need. You can read more about the coding styles at https://blog.newrelic.com/2015/04/01/python-programming-styles/.
  PYTHON’S CODING STYLES
 Most programming languages are dedicated to using just one coding style, which reduces
 flexibility for the programmer. However, Python is different. You can use a number of coding
 styles to achieve differing effects with Python. The four commonly used Python coding styles
  it’s useful to know that you aren’t trapped using a particular coding style. Because Python
 supports multiple coding styles and you can mix and match those styles in a single application,
 you have the advantage of being able to use Python in the manner that works best for a particular
  



















































































   54   55   56   57   58