Web-Books
in the Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Page - 59 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

Page - 59 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Image of the Page - 59 -

Image of the Page - 59 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition

Text of the Page - 59 -

3LoopsandBranching 3.1 TheforLoop Many computations are repetitive by nature and programming languages have certain loopstructures to dealwith this. Onesuch loopstructure is the for loop. 3.1.1 Example:Printingthe5TimesTable Assume the task is to print out the 5 times table. Before having learned about loop structures inprogramming,mostofuswouldfirst thinkofcoding this like: # Naively printing the 5 times table print(’{:d}*5 = {:d}’.format(1, 1*5)) print(’{:d}*5 = {:d}’.format(2, 2*5)) print(’{:d}*5 = {:d}’.format(3, 3*5)) print(’{:d}*5 = {:d}’.format(4, 4*5)) print(’{:d}*5 = {:d}’.format(5, 5*5)) print(’{:d}*5 = {:d}’.format(6, 6*5)) print(’{:d}*5 = {:d}’.format(7, 7*5)) print(’{:d}*5 = {:d}’.format(8, 8*5)) print(’{:d}*5 = {:d}’.format(9, 9*5)) print(’{:d}*5 = {:d}’.format(10, 10*5)) Β©The Author(s) 2020 S.Linge, H.P. Langtangen, Programming forComputations -Python, Texts in Computational Science and Engineering 15, https://doi.org/10.1007/978-3-030-16877-3_3 59
back to the  book Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Volume Second Edition
Title
Programming for Computations – Python
Subtitle
A Gentle Introduction to Numerical Simulations with Python 3.6
Volume
Second Edition
Authors
Svein Linge
Hans Petter Langtangen
Publisher
Springer Open
Date
2020
Language
English
License
CC BY 4.0
ISBN
978-3-319-32428-9
Size
17.8 x 25.4 cm
Pages
356
Keywords
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Category
Informatik
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python