HomePython Page 2 - Python 3.1: Programming Basics and Strings
Programming is Control - Python
Ready to take your first steps in Python? This three-part article series walks you through the basics, introducing important concepts such as strings. In this first part, you'll learn how programming is different from using a computer, how to install Python, and how to start using the Python shell. It is excerpted from the book Beginning Python: Using Python 2.6 and Python 3.1,, written by James Payne, Developer Shed Editor-in-Chief (Wrox, 2010; ISBN: 0470414634).
Programming a computer is very different from creating a program, as the word applies to people in real life. In real life, you ask people to do things, and sometimes you have to struggle mightily to ensure that your wishes are carried out — for example, if you plan a party for 30 people and assign two of them to bring the chips and dip and they bring the drinks instead, it is out of your control.
With computers that problem doesn’t exist. The computer does exactly what you tell it to do. As you can imagine, this means that you must pay some attention to detail to ensure that the computer does just what you want it to do.
One of the goals of Python is to program in blocks that enable you to think about larger and larger
projects by building each project as pieces that behave in well - understood ways. This is a key goal of a programming style known as object - oriented programming . The guiding principle of this style is that you can create reliable pieces that still work when you piece them together, that are understandable, and that are useful. This gives you, the programmer, control over how the parts of your programs run, while enabling you to extend your program as the problems you’re solving evolve.
Programming Copes with Change
Programs are run on computers that handle real - world problems; and in the real world, plans and circumstances frequently change. Because of these shifting circumstances, programmers rarely get the opportunity to create perfectly crafted, useful, and flexible programs. Usually, you can achieve only two of these goals. The changes that you will have to deal with should give you some perspective and lead you to program cautiously. With sufficient caution, you can create programs that know when they’re being asked to exceed their capabilities, and they can fail gracefully by notifying their users that they’ve stopped. In the best cases, you can create programs that explain what failed and why. Python offers especially useful features that enable you to describe what conditions may have occurred that prevented your program from working.
What All That Means Together
Taken together, these beginning principles mean that you’re going to be introduced to programming as a way of telling a computer what tasks you want it to do, in an environment where you are in control. You will be aware that sometimes accidents can happen and that these mistakes can be accommodated through mechanisms that offer you some discretion regarding how these conditions will be handled, including recovering from problems and continuing to work.