Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - 34 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - 34 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - 34 -

Bild der Seite - 34 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - 34 -

34 1 TheFirstFewSteps elegantly in the code, since it is possible to (put simply) try some statements, and if they go wrong, rather run some other code lines! This way, an exception is handled, and an unintended program stop (“crash”) is avoided. More about exceptionhandling inSect.5.2. Testing Code When a program finally runs without error messages, it might be tempting to think that Ah..., I am finished!. But no! Then comes program testing, youneedtoverify that theprogramdoesthecomputationsasplanned.This isalmost an art and may take more time than to develop the program, but the program is useless unless you have much evidence showing that the computationsare correct. Also,havingasetof (automatic) tests saveshugeamountsof timewhenyoufurther developtheprogram. VerificationVersusValidation Verification is important, but validation is equally important. It is great if yourprogramcan do the calculationsaccording to the plan,but is it the right plan? Put otherwise, you need to check that the computations run correctly accordingto the formulayou havechosen/derived.This is verification: doing thethingsright.Thereafter,youmustalsocheckwhethertheformulayouhave chosen/derivedis the right formula for the case you are investigating.This is validation:doing the right things. In the present book, it is beyond scope to question how well the mathe- maticalmodelsdescribea givenphenomenonin natureor engineering,as the answerusually involvesextensiveknowledgeof theapplicationarea.We will therefore limit our testing to theverificationpart. 1.8 ConcludingRemarks 1.8.1 ProgrammingDemandsYoutoBeAccurate! In this chapter, you have seen some examples of how simple things may be done in Python. Hopefully,you have tried to do the exampleson your own. If you have, most certainly you have discovered that what you write in the code has to be very accurate. Forexample, in ourprogramball_plot.py, wecalledlinspace in thisway t = np.linspace(0, 1, 1001) If thishad ratherbeenwritten t = np.linspace[0, 1, 1001) we would have got an error message ([was used instead of (), even if you and I wouldunderstandthemeaningperfectlywell! Remember that it isnot a humanthat runsyourcode, it is a machine.Therefore, evenif themeaningofyourcode looksfine toahumaneye, it still has tocomply in detail to the rules of the programming language. If not, you get warnings and error
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python