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

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

Image of the Page - 53 -

Image of the Page - 53 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python

Text of the Page - 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.
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
Web-Books
Library
Privacy
Imprint
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python