1 |
retostamm |
1.1 |
% Copyright 2002 Reto Stamm. |
2 |
|
|
% Permission is granted to copy, distribute and/or modify this document |
3 |
|
|
% under the terms of the GNU Free Documentation License, Version 1.1 |
4 |
|
|
% or any later version published by the Free Software Foundation; |
5 |
|
|
% with no Invariant Sections, with the Front-Cover Texts being |
6 |
|
|
% at least the original author and title. |
7 |
|
|
% A copy of the license is included in the section entitled ``GNU |
8 |
|
|
% Free Documentation License''. |
9 |
|
|
|
10 |
|
|
\chapter{Programming} |
11 |
|
|
|
12 |
|
|
\section{Tell the computer what to do} |
13 |
|
|
|
14 |
|
|
When you are programming, all you do is to tell the computer what to |
15 |
|
|
do. |
16 |
|
|
|
17 |
|
|
Example: Dear Computer, please Write ``Hello'' on the screen. Then, |
18 |
|
|
write all the numbers from 0 to 10, each on their own line. |
19 |
|
|
|
20 |
|
|
The Computer is really lazy, but also always does what you tell it to |
21 |
|
|
do. If you don't tell it to do something, it won't do it. If you are |
22 |
|
|
not really precise in telling it what to do, it will do something |
23 |
|
|
different from what you are expecting. |
24 |
|
|
|
25 |
|
|
When you tell people to do something, you expect them to think. Like this: |
26 |
|
|
|
27 |
|
|
\begin{itemize} |
28 |
|
|
|
29 |
|
|
\item Close the Door! (Of course Only if it's open.) |
30 |
|
|
\item Wash the dishes! (The dirty ones of course, not the clean ones.) |
31 |
|
|
\item Vacuum! (The carpet, not the ceiling!) |
32 |
|
|
|
33 |
|
|
\end{itemize} |
34 |
|
|
|
35 |
|
|
If you don't tell the computer exactly what needs to be done, it will |
36 |
|
|
get confused, do the wrong thing, do nothing at all, or complain. |
37 |
|
|
|
38 |
|
|
\section{Computer Languages} |
39 |
|
|
|
40 |
|
|
Computer Languages are the only thing the Computer understands. They |
41 |
|
|
are made so that the computer can not ``find excuses'' to do something |
42 |
|
|
else from what you are telling it to do. They are Simple. |
43 |
|
|
|
44 |
|
|
In a computer language\\ |
45 |
|
|
every Idea\\ |
46 |
|
|
or command\\ |
47 |
|
|
is on its own line. |
48 |
|
|
|
49 |
|
|
Kind of like a shopping list. That makes it easier for you to |
50 |
|
|
understand. The computer does not really care. |
51 |
|
|
|
52 |
|
|
There are many computer languages. They are all a bit different from |
53 |
|
|
each other, but not too much. |
54 |
|
|
|
55 |
|
|
|
56 |
|
|
\section{Python} |
57 |
|
|
|
58 |
|
|
Python is a computer language. |
59 |
|
|
|
60 |
|
|
print ``hello''; |
61 |
|
|
|
62 |
|
|
will write hello to the screen. |
63 |
|
|
|
64 |
|
|
x = read; |
65 |
|
|
|
66 |
|
|
will read what you type in. |
67 |
|
|
|
68 |
|
|
What will this do? |
69 |
|
|
|
70 |
|
|
print ``What's your name''; |
71 |
|
|
x = read; |
72 |
|
|
print ``Hello '', x; |