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 - 39 -
  • User
  • Version
    • full version
    • text only version
  • Language
    • Deutsch - German
    • English

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

Image of the Page - 39 -

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

Text of the Page - 39 -

2AFewMoreSteps 2.1 UsingPythonInteractively 2.1.1 TheIPythonShell Pythoncanalsobeusedinteractively, inwhichcasewedonotfirstwriteaprogram, store it in a file and then execute it. Rather, we give statements and expressions directly to what is knownas a Python shell. Thismeans that we communicatewith the Python interpretervia a particular interface. Interactiveuse of Python is a great waytoquicklydemonstratedifferentaspectsofPythonandwewilluse it repeatedly for this purpose. It is also very useful for testing out things like function behavior, syntax issues, etc., beforefinalizingrelatedcode in aprogramyouarewriting. We recommend to use IPython as shell (because it is superior to alternative Pythonshells).WithSpyder,Ipython isavailableatstartup,appearinginthelower right pane (the console).An interactive session appearsas a succession of pairwise corresponding input (to Python) and output (from Python). The user writes input commands after the IPython prompt1 In [p]:, wherep = 1,2,.. ., and gets the responseback (if any)afterOut [p]:. Thus,p serves as a counter for each pair of input and output (when there is no output, this “pair” will consist of only input). Toexemplify,we maywrite: In [1]: 2+2 Out[1]: 4 In [2]: 2*3 Out[2]: 6 In [3]: 10/2 # note: gives float Out[3]: 5.0 In [4]: 2**3 Out[4]: 8 1 A prompt means a “ready sign”, i.e. the program allows you to enter a command, and different programs often have different looking prompts. ©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_2 39
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