亚洲熟女综合色一区二区三区,亚洲精品中文字幕无码蜜桃,亚洲va欧美va日韩va成人网,亚洲av无码国产一区二区三区,亚洲精品无码久久久久久久

如何用Python進(jìn)行數(shù)學(xué)運(yùn)算 ?

今天小編要跟大家分享的文章是如何用Python進(jìn)行數(shù)學(xué)運(yùn)算?熟悉Python的小伙伴們都知道計(jì)算機(jī)本來(lái)就是用來(lái)進(jìn)行數(shù)學(xué)計(jì)算的,而且無(wú)論是C語(yǔ)言還Python,它都會(huì)被轉(zhuǎn)換成二進(jìn)制數(shù)字,來(lái)讓電腦識(shí)別,Python入門(mén)新手和正在Python學(xué)習(xí)的小伙伴快來(lái)看一看吧,希望能夠?qū)Υ蠹矣兴鶐椭?!

今天我們呢就學(xué)習(xí)一下如何用Python進(jìn)行數(shù)學(xué)運(yùn)算。

要學(xué)習(xí)數(shù)學(xué)計(jì)算然少不了運(yùn)算符了,我們這就先來(lái)認(rèn)識(shí)一下Python中的運(yùn)算符。

名字如下:

? + plus 加號(hào)
? - minus 減號(hào)
? / slash 斜杠
? * asterisk 星號(hào)
? % percent 百分號(hào)
? < less-than 小于號(hào)
? > greater-than 大于號(hào)
? <= less-than-equal 小于等于號(hào)
? >= greater-than-equal 大于等于

有沒(méi)有注意到以上只是些符號(hào),沒(méi)有運(yùn)算操作呢?寫(xiě)完下面的練習(xí)代碼后,再回到上面的列表,寫(xiě)出每個(gè)符號(hào)的作用。例如 + 是用來(lái)做加法運(yùn)算的。

1 print "I will now count my chickens:"

2

3 print "Hens", 25 + 30 / 6 4 print "Roosters", 100 - 25 * 3 % 4

5

6 print "Now I will count the eggs:"

7

8 print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

9

10 print "Is it true that 3 + 2 < 5 - 7?"

11

12 print 3 + 2 < 5 - 7

13

14 print "What is 3 + 2?", 3 + 2

15 print "What is 5 - 7?", 5 - 7

16

17 print "Oh, that's why it's False."

18

19 print "How about some more."

20

21 print "Is it greater?", 5 > -2

22 print "Is it greater or equal?", 5 >= -2

23 print "Is it less or equal?", 5 <= -2

通過(guò)上面代碼的運(yùn)行,你將得到下面的結(jié)果,自己動(dòng)手操作一下是不是正確呢?

$ Python ex3.py

I will now count my chickens:

Hens 30 Roosters 97

Now I will count the eggs:

7

Is it true that 3 + 2 < 5 - 7?

False

What is 3 + 2? 5 What is 5 - 7? -2

Oh, that's why it's False. How about some more.

Is it greater? True Is it greater or equal?

True Is it less or equal? False

$

以上就是一個(gè)用Python寫(xiě)的運(yùn)算實(shí)例,大家課下可以照著源碼多多練習(xí)一下。

以上就是馬哥教育今天為大家分享的關(guān)于如何用 Python進(jìn)行數(shù)學(xué)運(yùn)算的文章,希望本篇文章能夠?qū)φ?strong>學(xué)習(xí)Python?和從事Python相關(guān)工作的小伙伴們有所幫助,想要了解更多相關(guān)知識(shí)記得關(guān)注馬哥教育官網(wǎng),每天都會(huì)有大量?jī)?yōu)質(zhì)內(nèi)容與大家分享!

聲明:文章來(lái)源于網(wǎng)絡(luò),侵刪!

相關(guān)新聞

歷經(jīng)多年發(fā)展,已成為國(guó)內(nèi)好評(píng)如潮的Linux云計(jì)算運(yùn)維、SRE、Devops、網(wǎng)絡(luò)安全、云原生、Go、Python開(kāi)發(fā)專(zhuān)業(yè)人才培訓(xùn)機(jī)構(gòu)!