Seite - 3 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Bild der Seite - 3 -
Text der Seite - 3 -
1.2 APythonProgramwithVariables 3
arguments toother functions, there isgoodsupport for interfacingC,C++andFor-
tran code (i.e., a Python programmay use codewritten in other languages), and
functions explicitlywritten for scalar input oftenworkfine (withoutmodification)
alsowithvector input.Another important thing, is thatPython isavailable for free.
It canbedownloadedfromthe Internetandwill runonmostplatforms.
Readers who want to expand their scientific programming skills beyond the
introductory level of the present exposition, are encouraged to study the book
A Primer on Scientific Programming with Python [13]. This comprehensive book
is as suitable for beginners as for professional programmers, and teaches the art
of programming through a huge collection of dedicated examples. This book is
considered the primary reference, and a natural extension, of the programming
matters in thepresentbook.
Somecomputerscienceterms
Note that, quite often, the terms script and scripting are used as synonyms for
programandprogramming, respectively.
The inventor of thePerl programming language,LarryWall, tried to explain
thedifferencebetweenscript andprograminahumorousway(fromperl.com1):
Suppose you went back to Ada Lovelace2 and asked her the difference between
a script and a program. She’d probably look at you funny, then say something
like: Well, a script is what you give the actors, but a program is what you give
the audience. That Ada was one sharp lady ... Since her time, we seem to
have gotten a bit more confused about what we mean when we say scripting. It
confusesevenme, andI’msupposed tobe oneof theexperts.
Therearemanyotherwidelyusedcomputersciencetermstopickup.Writing
a program (or script or code) is often expressed as implementing the program.
Executing a programmeans running the program. An algorithm is a recipe for
how to construct a program. A bug is an error in a program, and the art of
trackingdownandremovingbugs iscalleddebugging.Simulatingorsimulation
refers to using a program tomimic processes in the real world, often through
solvingdifferential equations thatgovern thephysicsof theprocesses.
1.2 APythonProgramwithVariables
Ourfirst example regardsprogrammingamathematicalmodel thatpredicts thepo-
sition of a ball thrown up in the air. FromNewton’s 2nd law, and by assuming
negligibleair resistance,onecanderiveamathematicalmodel thatpredicts thever-
tical positiony of theball at time t. Fromthemodelonegets the formula
yDv0t 0:5gt2;
where v0 is the initial upwards velocity and g is the acceleration of gravity, for
which 9:81ms 2 is a reasonable value (even if it depends on things like location
on the earth). With this formula at hand, andwhenv0 is known, youmayplug in
avalue for timeandgetout thecorrespondingheight.
1http://www.perl.com/pub/2007/12/06/soto-11.html
2http://en.wikipedia.org/wiki/Ada_Lovelace
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2016
- Sprache
- englisch
- Lizenz
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 248
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik