Algorithms For Dummies


PART 1   Getting Started



Download 7,18 Mb.
Pdf ko'rish
bet150/651
Sana15.07.2021
Hajmi7,18 Mb.
#120357
1   ...   146   147   148   149   150   151   152   153   ...   651
Bog'liq
Algorithms

 

   


  PART 1 

 Getting Started

Doing arithmetic

Storing information in variables makes it easily accessible. However, to perform 

any useful work with the variable, you usually perform some type of arithmetic 

operation on it. Python supports the common arithmetic operators you use to 

perform tasks by hand. They appear in Table 4-2.

TABLE 4-1

Python Assignment Operators

Operator Description

Example

=

Assigns the value found in the right operand to the left operand



MyVar = 5 results in 

MyVar containing 5

+=

Adds the value found in the right operand to the value found in the left 



operand and places the result in the left operand

MyVar += 2 results in 

MyVar containing 7

-=

Subtracts the value found in the right operand from the value found in 



the left operand and places the result in the left operand

MyVar -= 2 results in 

MyVar containing 3

*=

Multiplies the value found in the right operand by the value found in the 



left operand and places the result in the left operand

MyVar *= 2 results in 

MyVar containing 10

/=

Divides the value found in the left operand by the value found in the 



right operand and places the result in the left operand

MyVar /= 2 results in 

MyVar containing 2.5

%=

Divides the value found in the left operand by the value found in the 



right operand and places the remainder in the left operand

MyVar %= 2 results in 

MyVar containing 1

**=


Determines the exponential value found in the left operand when raised 

to the power of the value found in the right operand and places the 

result in the left operand

MyVar ** 2 results in 

MyVar containing 25

//=


Divides the value found in the left operand by the value found in the right 

operand and places the integer (whole number) result in the left operand

MyVar //= 2 results in 

MyVar containing 2




Download 7,18 Mb.

Do'stlaringiz bilan baham:
1   ...   146   147   148   149   150   151   152   153   ...   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