Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7053327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:29:30+00:00 2026-05-28T03:29:30+00:00

In C/C++, comparison operators such as < > have higher priority than == does.

  • 0

In C/C++, comparison operators such as < > have higher priority than == does. This code will evaluate to true or 1:

if(3<4 == 2<3) {  //3<4 == 2<3 will evaluate to true
    ...
}

But in Python, it seems wrong:

3<4 == 2<3  #this will evaluate to False in Python.

In Python, does every comparison operator have the same priority?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:29:30+00:00Added an answer on May 28, 2026 at 3:29 am

    In Python, not only do comparison operators gave the same priority, they are treated specially (they chain rather than group). From the documentation:

    Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN are comparison operators, then a op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... and y opN z, except that each expression is evaluated at most once.

    In your case, the expression

    3<4 == 2<3
    

    is equivalent to

    3 < 4 and 4 == 2 and 2 < 3
    

    which is False due to the second clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just learning Perl's comparison operators. I tried the below code :- $foo=291;
Python 2.x has two ways to overload comparison operators, __cmp__ or the rich comparison
Does a comparison sort have to compare the A[i] largest and A[i+1] largest values?
I thought if statements weren't supposed to contain assignment operators but rather the comparison
Do pointers in C and C++ support comparison operators ( > , < ,
Good file comparison tools were already discussed to the pain, but my problem is
Is it possible, in any way, to pass comparison operators as variables to a
I have a set of classes something like this: abstract class CollectionAbs implements Iterator
How can one create an object that when its operators, such as: operator >
Sorting five integers using bitwise or comparison operators can be achieved by first getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.