A Concise Introduction to Programming in Python
eBook - ePub

A Concise Introduction to Programming in Python

Mark J. Johnson

Buch teilen
  1. 209 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

A Concise Introduction to Programming in Python

Mark J. Johnson

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

A Concise Introduction to Programming in Python, Second Edition provides a hands-on and accessible introduction to writing software in Python, with no prior programming experience required.

The Second Edition was thoroughly reorganized and rewritten based on classroom experience to incorporate:

  • A spiral approach, starting with turtle graphics, and then revisiting concepts in greater depth using numeric, textual, and image data


  • Clear, concise explanations written for beginning students, emphasizing core principles


  • A variety of accessible examples, focusing on key concepts


  • Diagrams to help visualize new concepts


  • New sections on recursion and exception handling, as well as an earlier introduction of lists, based on instructor feedback

The text offers sections designed for approximately one class period each, and proceeds gradually from procedural to object-oriented design. Examples, exercises, and projects are included from diverse application domains, including finance, biology, image processing, and textual analysis. It also includes a brief "How-To" sections that introduce optional topics students may be interested in exploring.

The text is written to be read, making it a good fit in flipped classrooms. Designed for either classroom use or self-study, all example programs and solutions to odd-numbered exercises (except for projects) are available at: http://www.central.edu/go/conciseintro/.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist A Concise Introduction to Programming in Python als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu A Concise Introduction to Programming in Python von Mark J. Johnson im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Programming Games. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2018
ISBN
9781351621984

CHAPTER 1

Turtle Graphics

This chapter introduces many of the fundamental concepts of computing using examples from turtle graphics.

1.1 GETTING STARTED

Programmable software is what makes a computer a powerful tool. Each different program essentially “rewires” the computer to allow it to perform a different task. By following this text, you will learn basic principles of writing software in the Python programming language.
Python is a popular scripting language available as a free download from www.python.org. Follow the instructions given there to install the latest production version of Python 3 on your system. All examples in this text were written with Python 3.6.
The CPU and RAM
In order to write software, it will be helpful to imagine what happens inside the computer when a program runs. We begin with a rough picture and gradually fill in details along the way.
When a program is ready to run, it is loaded into RAM, usually from long-term storage such as a network drive or flash drive. RAM is an acronym for random access memory, which is the working memory of a computer. RAM is volatile, meaning that it requires electricity to maintain its contents.
Once a program is loaded into RAM, the CPU, or central processing unit, executes the instructions of the program, one at a time. Each CPU family has its own instruction set, and you might be surprised at how limited these instruction sets are. Most instructions boil down to one of a few simple types: load data, perform arithmetic, make comparisons, and store data. It is amazing that these small steps can be combined in so many different ways to build software that is incredibly diverse and complex.
Computer Languages
CPU instruction sets are also known as machine languages. The key point to remember about machine languages is that in order to be run by a CPU, a program must be written in the machine language of that CPU. Unfortunately, machine languages are not meant to be read or written by humans. They are really just specific sequences of bits in memory. (We will explain bits later if you are not sure what they are.)
Because of this, people usually write software in a higher-level language, in the sense of Table 1.1. This ordering is not meant to be precise, but, for example, most programmers would agree that C and C++ are closer to the machine than Python.
TABLE 1.1 Programming language hierarchy
image
Compilation and Interpretation
Now if CPUs can only run programs written in their own machine language, how do we run programs written in Python, Java, or C++? The answer is that the programs are translated into machine language first.
There are two main types of translation: compilation and interpretation. When a program is compiled, it is completely translated into machine language to produce an executable file. C and C++ programs are usually compiled, and most applications you normally run have been compiled. In fact, many companies only distribute compiled executables: unless a project is open source, you do not have access to the uncompiled source code.
On the other hand, when a program is interpreted, it is translated “on-the-fly.” No separate executable file is created. Instead, the translator program (the interpreter) translates your program so that the CPU can execute it. Python programs are usually interpreted.
The Python Interpreter
When you start Python, you are in immediate contact with a Python interpreter. If you provide it with valid Python, the interpreter will translate your code so that it can be executed by the CPU. The interpreter displays the version of Python it was written for, and then shows that it is ready for your input with a “>>>” prompt. The interpreter will translate and execute any legal Python code that is typed at this prompt. For example, if we enter the following statement:
image
the interpreter will respond accordingly. Try it and see.
Remember that if you are not sure what something will do in Python, you can always try it out in the interpreter without having to write a complete program. Experiment—the interpreter will not mind.
A Python Program
That said, our focus will be on writ...

Inhaltsverzeichnis