Page - XI - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - XI -
Text of the Page - XI -
Contents
1 TheFirstFewSteps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 What Is aProgram?AndWhat IsProgramming? . . . . . . . . . . . 1
1.2 APythonProgramwithVariables . . . . . . . . . . . . . . . . . . . . 3
1.2.1 TheProgram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.2 Dissectionof theProgram. . . . . . . . . . . . . . . . . . . . . 4
1.2.3 WhyNot JustUseaPocketCalculator? . . . . . . . . . . . . 5
1.2.4 WhyYouMustUseaTextEditor toWritePrograms . . . . 6
1.2.5 InstallationofPython . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.6 Write andRunYourFirstProgram . . . . . . . . . . . . . . . 6
1.3 APythonProgramwithaLibraryFunction . . . . . . . . . . . . . . 7
1.4 APythonProgramwithVectorizationandPlotting . . . . . . . . . . 9
1.5 MoreBasicConcepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.5.1 UsingPythonInteractively . . . . . . . . . . . . . . . . . . . . 12
1.5.2 Arithmetics, ParenthesesandRoundingErrors . . . . . . . . 13
1.5.3 VariablesandObjects . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.4 IntegerDivision . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.5.5 FormattingText andNumbers . . . . . . . . . . . . . . . . . . 15
1.5.6 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.5.7 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5.8 ErrorMessagesandWarnings . . . . . . . . . . . . . . . . . . 21
1.5.9 InputData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.5.10 SymbolicComputations . . . . . . . . . . . . . . . . . . . . . . 23
1.5.11ConcludingRemarks . . . . . . . . . . . . . . . . . . . . . . . . 25
1.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2 BasicConstructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.1 IfTests,ColonandIndentation . . . . . . . . . . . . . . . . . . . . . . 29
2.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3 ForLoops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.4 WhileLoops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.5 Lists andTuples–Alternatives toArrays . . . . . . . . . . . . . . . . 41
2.6 Reading fromandWriting toFiles . . . . . . . . . . . . . . . . . . . . 43
2.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
xi
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