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

Operators

The document outlines various Python operators categorized into arithmetic, assignment, comparison, logical, identity, membership, and bitwise operators. Each category includes the operator symbol, its name or description, and examples of usage. This serves as a reference guide for understanding and utilizing Python operators in programming.

Uploaded by

SafaSöylem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Operators

The document outlines various Python operators categorized into arithmetic, assignment, comparison, logical, identity, membership, and bitwise operators. Each category includes the operator symbol, its name or description, and examples of usage. This serves as a reference guide for understanding and utilizing Python operators in programming.

Uploaded by

SafaSöylem
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Python Operators - Arithmetic

Operator Name

+ Addition

- Subtraction

* Multiplication

/ Division

% Modulus

** Exponentiation

// Floor division

Python for Finance and Business Alexander Hagmann 1


Python Operators - Assignment

Operator Example Same As

= a=3 a=3

+= a += 3 a=a+3

-= a -= 3 a=a-3

*= a *= 3 a=a*3

/= a /= 3 a=a/3

Python for Finance and Business Alexander Hagmann 2


Python Operators - Comparison

Operator Name Example

== Equal x == y

!= Not equal x != y

> Greater than x>y

< Less than x<y

>= Greater than or equal to x >= y

<= Less than or equal to x <= y

Python for Finance and Business Alexander Hagmann 3


Python Operators - Logical

Operator Description Example

and Returns True if both statements are true x < 5 and x < 10

or Returns True if one of the statements is true x < 5 or x < 4

not Reverse the result, returns False if the result is true not(x < 5 and x < 10)

Python for Finance and Business Alexander Hagmann 4


Python Operators - Identity

Operator Description Example

Returns true if both variables are


is x is y
the same object
Returns true if both variables are
is not x is not y
not the same object

Python for Finance and Business Alexander Hagmann 5


Python Operators - Membership

Operator Description Example

Returns True if a sequence with the


in x in y
specified value is present in the object
Returns True if a sequence with the
not in x not in y
specified value is not present in the object

Python for Finance and Business Alexander Hagmann 6


Python Operators - Bitwise

Operator Name Description

& AND Sets each bit to 1 if both bits are 1

| OR Sets each bit to 1 if one of two bits is 1

~ NOT Inverts all the bits

Python for Finance and Business Alexander Hagmann 7

You might also like