Python Programming for Biology: Bioinformatics and Beyond


Figure 3.3.  Starting the interactive Python interpreter on different operating



Download 7,75 Mb.
Pdf ko'rish
bet30/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   26   27   28   29   30   31   32   33   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Figure 3.3.  Starting the interactive Python interpreter on different operating

systems. For most computer systems the interactive interpreter is started by issuing the

‘python’ command at an operating-system prompt. For Windows systems the PATH

environment variable will need to be set first, however, as illustrated in

Figure 3.2

. Also,

for Windows the interpreter may be started by double-clicking on the ‘Python (command

line)’ icon (e.g. accessed via the start menu), or by double-clicking on the installed

‘python.exe’ file.

The print operation automatically converts anything that is not already a text string into

text for display. Hence, for example, you can print numbers:

print(127)

Also,  the  value  being  printed  might  not  be  explicitly  stated,  coming  instead  from  a

calculation or other operation:

print(1 + 2 + 4 + 8 + 16)

And  to  print  several  things  you  can  simply  separate  them  with  a  comma,  which  as

standard separates the printed items with a space:




print('The meaning of life is', 42)

If you want to see the value of some variable when running Python from a script file

you  need  to  explicitly  use  print.  However,  at  the  Python  prompt  just  giving  a  variable

name,  and  nothing  else,  on  a  line  will  print  it  out,  albeit  sometimes  slightly  differently.

Note  that  print  tidies  things  a  little  by  rounding  the  last  few  decimal  places,  which  is

normally what you want:

>>> x = 0.333333333333333

>>> print(x)

0.333333333333

>>> x


0.333333333333333

>>>


Throughout our examples we will be adding comments to the Python commands. These

describe  what  is  going  on  at  a  given  point  in  the  code,  and  we  encourage  you  to  add

helpful explanations to the relevant points in your programs. Even though such comments

are passed into the Python interpreter, they are ignored and serve no purpose other than to

inform anyone who reads the code. In Python, single-line comments are introduced with

the ‘#’ character, and everything after this character on that line constitutes the comment.

Comments may go on a line of their own, but it is common practice to add them after a

command. The example below illustrates the addition of a comment to the end of a line,

which otherwise adds two numbers. As will be discussed below, do not be tempted to put

a space at the beginning of the line.

>>> 2+2 # this is a comment

4

>>>




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   26   27   28   29   30   31   32   33   ...   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