0% found this document useful (0 votes)
5 views

Logic and Bitwise Operators

python - pcep notes exam

Uploaded by

Muthuu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Logic and Bitwise Operators

python - pcep notes exam

Uploaded by

Muthuu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Logic and Bitwise Operators:

- `and`: A binary operator with lower precedence than comparison operators.


- `or`: Has lower precedence than `and`.
- `not`: A unary operator used for logical negation.
- Operators include `&`, `|`, `~`, and `^`.
- These operators require integer arguments; floats are not supported.

Operator Precedence:

| Priority | Operator |
|----------|---------------------------|
|1 | `~`, `+`, `-` (unary) |
|2 | `**` |
|3 | `*`, `/`, `//`, `%` |
|4 | `+`, `-` (binary) |
|5 | `<<`, `>>` |
|6 | `<`, `<=`, `>`, `>=` |
|7 | `==`, `!=` |
|8 | `&` |
|9 | `|` |
| 10 | `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `^=`, `|=`, `>>=`, `<<=` |

Lists:

- A list is a collection where each element is a scalar.


- Lists are ordered and can be modified (mutable).
- A function operates independently and is called as `result = function(arg)`.
- A method is associated with the data it acts upon and is called as
`data.method(arg)`.
- `[::2]`: Specifies start, end, and step; here, the step is 2.

You might also like