- Hands-On Penetration Testing with Python
- Furqan Khan
- 187字
- 2021-07-02 14:13:52
Python operators
An operator in Python is something that can carry out arithmetic or logical operations on an expression. The variable on which the operator operates is called the operand. Let's try to understand the various operators that are available in Python:
- Arithmetic:

- Assignment:
- a = 0 evaluates to a=0
- a +=1 evaluates to a = a + 1
- a -= 1 evaluates to a = a + 1
- a *= 2 evaluates to a = a * 2
- a /= 5 evaluates to a = a / 5
- a **= 3 evaluates to a = a ** 3
- a //= 2 evaluates to a= a // 2 (floor division 2)
- a %= 5 evaluates to a= a % 5
- Logical operators:
- and: True: If both the operands are true, then the condition becomes true. For example, (a and b) is true.
- or: True: If any of the two operands are non-zero, then the condition becomes true. For example, (a or b) is true.
- not: True: This is used to reverse the logical state of its operand. For example, not (a and b) is false.
- Bitwise operators:

推薦閱讀
- Learn ECMAScript(Second Edition)
- Functional Python Programming
- 流量的秘密:Google Analytics網(wǎng)站分析與優(yōu)化技巧(第2版)
- Django開發(fā)從入門到實踐
- PHP 編程從入門到實踐
- MySQL數(shù)據(jù)庫基礎(chǔ)實例教程(微課版)
- 西門子S7-200 SMART PLC編程從入門到實踐
- Android Studio開發(fā)實戰(zhàn):從零基礎(chǔ)到App上線 (移動開發(fā)叢書)
- Python機器學(xué)習(xí)與量化投資
- SCRATCH編程課:我的游戲我做主
- Java服務(wù)端研發(fā)知識圖譜
- Getting Started with Windows Server Security
- Unity虛擬現(xiàn)實開發(fā)圣典
- R語言與網(wǎng)站分析
- 信息學(xué)競賽寶典:基礎(chǔ)算法