Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet26/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   22   23   24   25   26   27   28   29   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

3

Python basics

Contents

Introducing the fundamentals

Getting started

Whitespace matters

Using variables

Simple data types

Arithmetic

String manipulation

Collection data types

List and tuple manipulation

Set manipulation

Dictionary manipulation

Importing modules

Introducing the fundamentals

Python  is  a  powerful,  general-purpose  computing  language.  It  can  be  used  for  large  and

complicated  tasks  or  for  small  and  simple  ones.  Naturally,  to  get  people  started  with  its

use,  we  begin  with  relatively  straightforward  examples  and  then  afterwards  increase  the

complexity.  Hence,  in  the  next  two  chapters  we  cover  most  of  the  day-to-day

fundamentals  of  the  language.  You  will  need  to  be,  at  least  a  little,  familiar  with  these

ideas  to  appreciate  the  subsequent  chapters.  Much  of  what  we  illustrate  here  is  called

scripting,  although  there  is  no  hard  and  fast  rule  about  what  is  deemed  to  be  a  program

and what is ‘merely’ a script. We will use the terminology interchangeably.

Here we describe most of the common operations and the basic types of data, but some

aspects will be left to dedicated chapters. Initially the focus will be on the core data types

handled  by  Python,  which  basically  means  numbers  and  text.  With  numbers  we  will  of

course describe doing arithmetic operations and how this can be moved from the specific

into the abstract using variables. All the other kinds of data in Python can also be worked

with  in  a  similarly  abstract  manner,  although  the  operations  that  are  used  to  manipulate

non-numeric  data  won’t  be  mathematical.  Moving  on  from  simple  numbers  and  text  we

will describe some of the other standard types of Python data. Most notable of these are

the collection types that act as containers for other data, so, for example, we could have a

list of words or a set of numbers, and the list or set is a named entity in itself; just another



item  that  we  can  give  a  label  to  in  our  programs.  Python  also  has  the  ability  to  let  you

describe  your  own  types  of  data,  by  making  an  object  specification  called  a  class.

However, this will be discussed in

Chapter 7

. We will end this chapter by introducing the

idea  of  importing  Python  modules,  which  is  a  mechanism  to  allow  a  program  to  access

extra functionality contained in separate files.

Finally, using Python is not only about the operation of programs, it is also important to

consider  what  it  means  to  the  people  who  read  it.  Hopefully  you  will  be  writing  clearly

understandable  code,  with  meaningful  variable  names  and  such  like.  Nonetheless,  it  is  a

good idea, when using any programming language, to get into the habit of adding human-

readable  comments  to  your  programs,  especially  at  points  where  the  logic  of  what  is

happening  is  not  so  obvious.  Such  comments  are  simply  textual  descriptions  that  are

separate from the functional part of the code. In Python, comments are usually introduced

using  the  hash  symbol

1

 ‘#’,  whereupon  all  subsequent  text  on  that  line  is  for  humans  to



read and not part of the program proper.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   22   23   24   25   26   27   28   29   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish