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

Seite - 53 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Bild der Seite - 53 -

Bild der Seite - 53 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text der Seite - 53 -

2.7 Exercises 53 c) Writea functionmystruct(text)thatcounts thenumberofacertainstructure in thestringtext. Thestructure isdefinedasG followedbyAorTuntiladouble GG. Perform amanual search for the structure too to control the computations bymystruct. Filename:count_substrings.py. Remarks You are supposed to solve the tasks using simple programming with loops andvariables. While a) andb) are quite straightforward, c) quickly involves demanding logic. However, there are powerful tools available in Python that can solve the tasks efficiently inverycompact code: a)text.count(letter)/float (len(text));b)text.count(letter*2);c)len(re.findall(’G[AT]+?GG’, text)). That is, there is rich functionality foranalysisof text inPythonand this is particularlyuseful inanalysisofgenesequences. OpenAccess This chapter is distributed under the termsof theCreativeCommonsAttribution- NonCommercial 4.0 International License (http://creativecommons.org/licenses/by-nc/4.0/), which permits any noncommercial use, duplication, adaptation, distribution and reproduction in anymediumor format, as long as you give appropriate credit to the original author(s) and the source, a link isprovided to theCreativeCommons licenseandanychangesmadeare indicated. The images or other third party material in this chapter are included in thework’s Creative Commons license, unless indicated otherwise in the credit line; if suchmaterial is not included in thework’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt or reproduce thematerial.
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2016
Sprache
englisch
Lizenz
CC BY-NC 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
248
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