Solving a Problem Using a Computer

The process of solving a problem using a computer begins with a detailed specification of the problem to be solved. Unless the problem is completely un­derstood, its solution on a computer is impossible. Then we examine the problem to see what methods that we know about and what programs we already have could be used in its solution. At this stage we’re diving the problem in to the part that we know how to solve right away, and the part that we do not. The latter part has to be examined in more detail until a solution can be proposed. Then we create an outline of the solution, often on paper using human language; this is pseudocode, and differs in style from person to person. This is translated into computer language and then typed into computer form using a keyboard. The resulting text file is called a script, source code, or more commonly just the com­puter program.

A program called a compiler takes this program and converts it into a form that can be executed on the computer. Basically, all programs are converted into a set of numbers called machine code which the computer can execute.

We are going to learn a language called Python. It was developed as a gener­al-purpose programming language and is a good language for teaching because it makes a lot of things easy. Quite a few applications are built using Python, such as the games Eve Online and Civilization IV, BitTorrent, and Dropbox. It is a bit like a lot of other languages in use these days in terms of structure (syntax) but has some simplifying ideas that will be discussed in later chapters.

In order to use a programming language there are some basic concepts and structures that need to be understood at a basic level. Some of these concepts are introduced in this chapter and the rest of the book teaches you to program by example; in all cases, coding examples are introduced by stating a problem to be solved. The problems to be solved in this chapter include a simple guess- a-number game and the game of rock-paper-scissors. These problems serve as the motivation for learning more about either the Python language itself or about methods of solving problems. Any computer programs in this book will execute on a computer running any major operating system once the free Python lan­guage download has been installed.


Source: Parker James R. (2021), Python: An Introduction to Programming, Mercury Learning and Information; Second edition.

Leave a Reply

Your email address will not be published. Required fields are marked *