官术网_书友最值得收藏!

Arithmetic operations

Python enables performing all the standard arithmetic operations. Let's launch the Python interpreter and learn more:

  • Addition: Two numbers can be added using the + operand. The result is printed on the screen. Try the following example using the python interpreter:
       >>>123+456 
579
  • Subtraction: Two numbers can be added using the - operand:
       >>>456-123 
333
>>>123-456
-333
  • Multiplication: Two numbers can be multiplied as follows:
       >>>123*456 
56088
  • Division: Two numbers can be pided as follows:
       >>>456/22 
20.727272727272727
>>>456/2.0
228.0
>>>int(456/228)
2
  • Modulus operator: In Python, the modulus operator (%) returns the remainder of a pision operation:
       >>>4%2 
0
>>>3%2
1
  • The floor operator (//) is the opposite of the modulus operator. This operator returns the floor of the quotient, that is, the integer result, and discards the fractions:
       >>>9//7 
1
>>>7//3
2
>>>79//25
3
主站蜘蛛池模板: 塘沽区| 建德市| 宝清县| 永川市| 新闻| 化州市| 九江市| 桓台县| 瑞丽市| 望都县| 武夷山市| 永济市| 莲花县| 清新县| 临泽县| 邻水| 宁海县| 临湘市| 永川市| 新巴尔虎右旗| 广河县| 南岸区| 大田县| 来安县| 昌图县| 囊谦县| 衢州市| 河池市| 庆安县| 崇左市| 小金县| 佛冈县| 都兰县| 宁明县| 宁津县| 清水河县| 志丹县| 息烽县| 屏南县| 元江| 寿光市|