DEV Community

pagarsach14
pagarsach14

Posted on

1

Python Operators Precedence Example

Hello everyone, welcome to DEV 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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay