Programming for idiots_ Python programming for beginners.pdf

(921 KB) Pobierz
THE BASES
PROGRAMMING
BY EXAMPLE LANGUAGE PYTHON
CHAPTER 1. BASICS OF BASICS
“ Computer science is no more a science about computers than astronomy is
the science of telescopes . "
(Edsger Dijkstra)
“ There are two types of programming languages - those that all scold, and
those on which no one writes . "
(B. Stroustrup, developer of the C ++ programming language)
In order to learn to swim, you need to enter the water and start trying to row.
with your hands, helping yourself with your legs, then fighting the fear, break
away from the bottom and swim. Is in this is similar to writing programs.
You can read a thick textbook, pass credit / exam at the university, but at the
same time not learn how to write even simple programs.
How much time to spend on training? The musicians say that to achieve
mastery of the instrument must be rehearsed for four hours a day.
The programmer's tool is a computer, so let's take a quick look at it.
device. All calculations in the computer are performed by the central
processor.
Files with programs are stored in permanent memory (on a hard disk), and at
the moment executions are loaded into a temporary (RAM) memory.
Entering information into computer is carried out using keyboard (input
device), and the output is with using a monitor (output device).
The computer can only work with two types of signals: 1 or 0 (machine
code). Write programs kind
1010101010010101010 is difficult for a person, his thinking is arranged
differently, therefore language translator programs appeared human-readable
programming on machine language that a computer can understand.
Languages
programming, which
close to the machine level, called low-level languages (for example,
language
assembler). Another kind of languages are high-level languages (e.g.
Python, Java, C #), more more close to human thinking.
D. Yu. Fedorov. "Fundamentals of programming using the example of the
Python language"
Programming languages have an interesting history. They were not created
from scratch, but for specific tasks facing their developers at that time, from
here the scope of application of this or that programming language becomes
clear. On the today there are thousands of programming languages, but the
greatest role played only a few of them.
Earlier we said that the machine code served as the beginning of
communication with the computer. Then in the 50s of the twentieth century, a
low-level assembly language appeared, the most close to the machine level.
It's CPU bound, so learning it
is tantamount to learning about processor architecture. Programs are written
in assembly language and today, it is indispensable in the case of small
devices (microcontrollers) with very limited memory resources.
The next stage is the emergence of the Fortran language, intended for
mathematical calculations.
Over time, the need for new staff and the need for training grew
programming. Learning in assembly languages or Fortran required a lot of
effort,
therefore, in the 60-70s, a galaxy of languages for learning appeared: Basic,
Pascal. Pascal language still used in schools as the main language of
instruction programming.
At the same time, research is underway in the development of operating
systems, which leads to the emergence of the UNIX system. This operating
system was originally written in assembly language, which made it difficult
to modify and learn, then D. Ritchie developed the C language for system
programming and together with B. Kernighan rewrote the UNIX system in
this language. Subsequently, the UNIX operating system became widespread
(its GNU / Linux clones are better known these days), and
along with it, a lot of programmers appeared for whom the C language
became native. Writing programs in this language requires good
qualifications from the programmer, because an unnoticed error can lead to
serious consequences in the program's operation.
Until now, the C language is in the lead as a language for systems
programming.
The next stage (80s) is characterized by the emergence of object oriented
programming (OOP), which was supposed to make it easier to create major
industrial programs. A scientist appears - B. Stroustrup, who
the capabilities of the C language were not enough, so it extends this
language by adding OOP. The new language was named C ++.
In the 90s, personal computers and the Internet appeared, because new
technologies and programming languages are required. At this moment is
gaining popularity of the Java language, which allows you to start writing
large applications without fear of seriously messing up the system. The Java
language was created with looking back at C ++ and with the future
development of the Internet. This language is characterized by portability of
their programs, i.e. by writing a Java program in personal computer, you can
run it on the coffee machine if there is a virtual Java machine.
Python appears at about the same time as Java. Language developer -
mathematician Guido van Rossum spent a long time developing the ABC
language for
learning programming. In one of the interviews, he answered the question
about the type programmers for whom Python would be interesting: “ I
imagined professional programmers in UNIX or UNIX-like environment.
Guides for
early versions of Python heralded something like “Python closes the gap
between C and shell programming ", because that was what interested me and
my closest colleagues. It never occurred to me that Python could be good
language for embedding into applications, until they began to ask me about it.
What it has proven to be useful for teaching the beginnings of programming
in school or college, a fluke due to many characteristics of ABC that I
retained: ABC was specially designed for teaching programming
non-programmers ". We will return to Python later, but for now we will
continue our historical excursion.
With the growth of the Internet, it was required to create dynamic sites -
Zgłoś jeśli naruszono regulamin