HomePython Python 3.1: Programming Basics and Strings
Python 3.1: Programming Basics and Strings
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).
If you like what you're reading here, you can find it at Wrox or purchase the entire book at Amazon.
How Programming is Different from Using a Computer
The first thing you need to understand about computers when you’re programming is that you control the computer. Sometimes the computer doesn’t do what you expect, but even when it doesn’t do what you want the first time, it should do the same thing the second and third time — until you take charge and change the program. The trend in personal computers has been away from reliability and toward software being built on top of other, unreliable, software. The results that you live with might have you believing that computers are malicious and arbitrary beasts, existing to taunt you with unbearable amounts of extra work and various harassments while you’re already trying to accomplish something. However, after you’ve learned how to program, you gain an understanding of how this situation has come to pass, and perhaps you’ll find that you can do better than some of the programmers whose software you’ve used.
Note that programming in a language like Python, an interpreted language, means that you are not going to need to know a whole lot about computer hardware, memory, or long sequences of 0s and 1s. You are going to write in text form like you are used to reading and writing but in a different and simpler language. Python is the language, and like English or any other language(s) you speak, it makes sense to other people who already speak the language. Learning a programming language can be even easier, however, because programming languages aren’t intended for discussions, debates, phone calls, plays, movies, or any kind of casual interaction. They’re intended for giving instructions and ensuring that those instructions are followed. Computers have been fashioned into incredibly flexible tools that have found a use in almost every business and task that people have found themselves doing, but they are still built from fundamentally understandable and controllable pieces.
Programming is Consistency
In spite of the complexity involved in covering all of the disciplines into which computers have crept, the basic computer is still relatively simple in principle. The internal mechanisms that define how a computer works haven’t changed a lot since the 1950s when transistors were first used in computers. In all that time, this core simplicity has meant that computers can, and should, be held to a high standard of consistency. What this means to you, as the programmer, is that anytime you tell a computer to metaphorically jump, you must tell it how high and where to land, and it will perform that jump — over and over again for as long as you specify. The program should not arbitrarily stop working or change how it works without you facilitating the change.