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 - 96 -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

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

Bild der Seite - 96 -

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

Text der Seite - 96 -

96 4 FunctionsandtheWritingofCode will be regarded as the final version (in general, however, programs are typically changedandimprovedagainandagain,makingithardtoreach the“final”version!). DevelopingaComputationalPlan To write a program, you need to plan what that program should do, and a good plan requires a thorough understanding of the addressed problem. One fundamentally important thing with the step-wise strategy, is that it invites you to think through your computational problem very carefully: What bits and pieces, or “sub-problems”, make up the whole task? Should the “sub- problems” be solved in any particular order, i.e., do parts of the problem depend on results from other parts? What is the best way to compute each of the “sub-problems”? This kind of thinking, which combines favorably with discussions among students/colleagues, often pays off in terms of a much deeper understanding of the problemat hand.Goodsolutionsoften requiresuchanunderstanding. CompoundStatements Theconstructionsmet in thischapter,and thepreviouschapter,arecharacter- ized by a grouping of statements that generally span several lines (although it is possible to write simpler cases on a single line, when statements are separated with a semi-colon). Such constructions are often referred to as compoundstatements, havingheaders (endingwitha colon)andbodies (with indentedstatements).a Interactive handling of compound statements is straight forward. For example,afor loopmaybewritten (andexecuted) like In [1]: for i in [1, 2, 3]: # write header, press enter ...: print(i) # indent comes automatically ...: # press only enter, i.e., finished 1 2 3 When the header has been typed in and we press enter, we are automatically given the indent on the next line. We can then proceed directly by writing print(i) and press enter again. We then want to finish our loop, which is understoodwhenwesimplypressenter,writingnothingelse. a https://docs.python.org/3/reference/compound_stmts.html.
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