Page - 6 - in Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - 6 -
Text of the Page - 6 -
6 1 TheFirstFewSteps
foreverymilli-secondof theflight?All thatpunchingon thecalculatorwouldhave
takenyou something like four hours! If youknowhow toprogram, however, you
couldmodify the codeabove slightly, using aminute or twoofwriting, and easily
get all the positions computed in one gowithin a second. Amuch stronger argu-
ment,however, is thatmathematicalmodelsfromreal lifeareoftencomplicatedand
comprehensive. The pocket calculator cannot copewith such problems, even not
theprogrammableones,because their computationalpowerandtheirprogramming
toolsare far tooweakcompared towhat a real computercanoffer.
1.2.4 WhyYouMustUseaTextEditortoWritePrograms
WhenPython interprets some code in a file, it is concernedwith every character
in thefile, exactly as itwas typed in. Thismakes it troublesome towrite the code
into a filewithword processors like, e.g.,MicrosoftWord, since such a program
will insert extra characters, invisible to us,with informationonhow to format the
text (e.g., the font size and type). Such extra information is necessary for the text
tobenicely formatted for thehumaneye. Python,however,will bemuchannoyed
by the extra characters in the file inserted by a word processor. Therefore, it is
fundamental that youwrite your program in a text editorwherewhat you type on
the keyboard is exactly the characters that appear in the file and that Pythonwill
later read. There are many text editors around. Some are stand-alone programs
like Emacs, Vim, Gedit, Notepad++, and TextWrangler. Others are integrated in
graphical development environments for Python, such as Spyder. This bookwill
primarily refer toSpyderand its texteditor.
1.2.5 InstallationofPython
Youwill need access to Python and several add-onpackages for doingmathemat-
ical computations and display graphics. An obvious choice is to install a Python
environment for scientific computingonyourmachine. Alternatively, you canuse
cloud services for runningPython, or you can remote login on a computer system
ataschooloruniversity.Availableandrecommended techniques forgettingaccess
toPythonand theneededpackagesaredocumented inAppendixA.
Thequickestway toget startedwith aPython installation for this bookonyour
Windows,Mac,orLinuxcomputer, is to installAnaconda3.
1.2.6 WriteandRunYourFirstProgram
Reading only does not teach you computer programming: you have to program
yourself andpractice heavilybeforeyoumastermathematical problemsolvingvia
programming. Therefore, it is crucial at this stage that youwrite and runaPython
program. We justwent through the programball.py above, so let us nextwrite
and run that code.
3http://continuum.io/downloads
back to the
book Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations β Python
A Gentle Introduction to Numerical Simulations with Python
- Title
- Programming for Computations β Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2016
- Language
- English
- License
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 248
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik