Backtworace
2 min readJul 19, 2020

Python Operators Precedence Example

Hello everyone, welcome to kaggle community today we will see python operator
so let’s start:
The following table lists all operators from highest precedence to lowest.

[Operator Description]
** Exponentiation (raise to the power)
~ + — Complement, unary plus and minus (method names for the last two are +@ and -@)

  • / % // Multiply, divide, modulo and floor division
  • - Addition and subtraction

<< Right and left bitwise shift & Bitwise ‘AND’td>
^ | Bitwise exclusive
OR' and regularOR'
>= Comparison operators
<> == != Equality operators
= %= /= //= -= += *= **= Assignment operators
is is not Identity operators
in not in
Membership operators
example
a = 20
b = 10
c = 15
d = 5
e = 0

e = (a + b) * c / d #( 30 * 15 ) / 5
print “Value of (a + b) * c / d is “, e

e = ((a + b) * c) / d # (30 * 15 ) / 5
print “Value of ((a + b) * c) / d is “, e

e = (a + b) * (c / d); # (30) * (15/5)
print “Value of (a + b) * (c / d) is “, e

e = a + (b * c) / d; # 20 + (150/5)
print “Value of a + (b * c) / d is “, e
When you execute the above program, it produces the following result list

Value of (a + b) * c / d is 90
Value of ((a + b) * c) / d is 90
Value of (a + b) * (c / d) is 90
Value of a + (b * c) / d is 50
references: https://www.pythonslearning.com/2020/07/greater-than-or-equal-to-python.html

Backtworace
Backtworace

Written by Backtworace

I am founder of <a href=”https://pythonslearning.com”>pythonslearning</a>

No responses yet