-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyoperators.py
More file actions
58 lines (48 loc) · 1.27 KB
/
Copy pathpyoperators.py
File metadata and controls
58 lines (48 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
In Python, the available operators are:
1. Arithmetic Operators:
- Addition: +
- Subtraction: -
- Multiplication: *
- Division: /
- Modulus: %
- Exponentiation: **
- Floor division: //
2. Comparison Operators:
- Equal: ==
- Not equal: !=
- Greater than: >
- Less than: <
- Greater than or equal to: >=
- Less than or equal to: <=
3. Assignment Operators:
- Assign: =
- Add and assign: +=
- Subtract and assign: -=
- Multiply and assign: *=
- Divide and assign: /=
- Modulus and assign: %=
- Exponentiate and assign: **=
- Floor divide and assign: //=
4. Logical Operators:
- And: and
- Or: or
- Not: not
5. Bitwise Operators:
- And: &
- Or: |
- Not: ~
- XOR: ^
- Right shift: >>
- Left shift: <<
6. Membership Operators:
- In: in
- Not in: not in
7. Identity Operators:
- Is: is
- Is not: is not
In Python, the equivalent of bash's [ if <esp> -eq <test>] do; is:
```python
if expression == test:
do_something
```
Here, 'expression' is the condition you want to test, '==' is the comparison operator, and 'do_something' is the action you want to perform if the condition is true. Python uses indentation (spaces or tabs) to define code blocks, unlike bash which uses 'do' and 'done'.