Algorithms For Dummies


Introducing Python for Algorithm Programming



Download 7,18 Mb.
Pdf ko'rish
bet159/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   155   156   157   158   159   160   161   162   ...   651
Bog'liq
Algorithms

  Introducing Python for Algorithm Programming 

     75


Because the computer doesn’t really understand strings, but strings are so useful 

in writing applications, you sometimes need to convert a string to a number. You 

can use the 

int()


 and 

float()


 commands to perform this conversion. For exam-

ple, if you type myInt 



= int("123") and press Enter at the Python prompt, you 

create an 

int

 named 


myInt

 that contains the value 

123

.

You can convert numbers to a string as well by using the 



str()

 command. For 

example, if you type myStr 

= str(1234.56) and press Enter, you create a string 

containing the value 

"1234.56"

 and assign it to 

myStr

. The point is that you can 



go back and forth between strings and numbers with great ease. Later chapters 

demonstrate how these conversions make many seemingly impossible tasks quite 

doable.

As with numbers, you can use some special operators with strings (and many 

objects). The member operators enable you to determine when a string contains 

specific content. Table 4-8 shows these operators.

The discussion in this section also makes it obvious that you need to know the 

kind of data that variables contain. You use the identity operators to perform this 

task, as shown in Table 4-9.


Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   155   156   157   158   159   160   161   162   ...   651




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
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