- Mastering Python Networking
- Eric Chou
- 137字
- 2021-07-02 21:42:33
Python operators
Python has the some numeric operators that you would expect; note that the truncating division, (//, also known as floor division) truncates the result to an integer and a floating point and return the integer value. The integer value is returned. The modulo (%) operator returns the remainder value in the division:
>>> 1 + 2
3
>>> 2 - 1
1
>>> 1 * 5
5
>>> 5 / 1
5.0
>>> 5 // 2
2
>>> 5 % 2
1
There are also comparison operators:
>>> a = 1
>>> b = 2
>>> a == b
False
>>> a > b
False
>>> a < b
True
>>> a <= b
True
We will also see two of the common membership operators to see whether an object is in a sequence type:
>>> a = 'hello world'
>>> 'h' in a
True
>>> 'z' in a
False
>>> 'h' not in a
False
>>> 'z' not in a
True
推薦閱讀
- Getting Started with React
- Spring 5企業(yè)級開發(fā)實戰(zhàn)
- CMDB分步構建指南
- Java Web應用開發(fā)技術與案例教程(第2版)
- 硅谷Python工程師面試指南:數據結構、算法與系統(tǒng)設計
- Getting Started with Hazelcast(Second Edition)
- AIRIOT物聯(lián)網平臺開發(fā)框架應用與實戰(zhàn)
- Java網絡編程實戰(zhàn)
- 從零開始:UI圖標設計與制作(第3版)
- Parallel Programming with Python
- Python程序員面試算法寶典
- 數據分析從入門到進階
- jMonkeyEngine 3.0 Cookbook
- Android 3D游戲開發(fā)技術寶典:OpenGL ES 2.0
- 數據結構和算法(Python和C++語言描述)