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

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
主站蜘蛛池模板: 永吉县| 新沂市| 秦皇岛市| 柳江县| 瓮安县| 龙江县| 孝义市| 黄平县| 平武县| 惠东县| 新余市| 仪征市| 澳门| 青浦区| 高青县| 元朗区| 高唐县| 扶绥县| 吐鲁番市| 含山县| 日喀则市| 原平市| 长汀县| 涟源市| 文成县| 宝应县| 芮城县| 米泉市| 佛学| 五家渠市| 澄城县| 汝州市| 姚安县| 甘孜县| 襄樊市| 和林格尔县| 岳阳市| 闸北区| 宝坻区| 开封市| 赤城县|