Python數學運算

來源:互聯網
上載者:User

標籤:pre   減法   判斷   div   print   list   加法   返回   als   

python中的加減乘除比其他的語言簡單,不需要對其賦值變數

(1)加減乘除

>>> print(1+10)    #加法11>>> print(10-1)      #減法9>>> print(10*1)     #乘法10>>> print(10/2)      #除法5.0>>> print(10**2)    #乘方100

(2)判斷

判斷返回的是True或者False

>>> print(5==5) #等於True>>> print(5!=5)   #不等於False>>> print(5>5)    #大於,>= 大於等於False>>> print(6<7)    #小於 ,<= 小於等於True>>> print(5 in [1,2,3,4,5])  #5在list中True

(3)邏輯運算子 AND,OR,NOT

>>> print(True or False)  # or, "或"運算, 其中之一為真即為真True>>> print(False and true) # and, “與”運算, 兩者都為真才是真False>>> print(not False)  # not, “非”運算, 取反True

 

Python數學運算

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.