What are Relational Operators in Python? | Scaler Topics (2024)

Relational Operators in python compare the operand values on either side. The relational operators in Python return a boolean value, i.e., either True or False based on the value of operands.

In simple terms, we can say that Relational operators are used for comparing the values. The relational operators are also known as Comparison Operators. There are six relational operators in Python.

Note:Relational operators in Python are the same in all versions of Python.

List of Relational Operators in Python

As we know, relational operators in python are used to compare the operand values on either side. Refer to the list below for the entire list of relational operators in python.

OperatorNameDescriptionSyntax
==Equal ToEqual to operator returns True if the first operand is equal to the second operand. Else, it returns False.operand1 == operand2
!=Not Equal ToNot Equal to operator returns True if the first operand is not equal to the second operand. Else, it returns False.operand1 != operand2
>Greater ThanGreater Than operator returns True if the first operand is greater than the second operand. Else, it returns False.operand1 > operand2
<Less ThanLess Than operator returns True if the first operand is lesser than the second. Else, it returns False.operand1 < operand2
>=Greater Than or Equal ToGreater Than or Equal To operator returns True if the first operand is greater than or equal to the second operand. Else, it returns False.operand1 >= operand2
<=Lesser Than or Equal ToLess Than or Equal To operator returns True if the first operand is less than or equal to the second operand. Else, it returns False.operand1 <= operand2

Examples of Relational Operators in Python

Let us learn each one of the relational operators in Python separately by taking examples.

Example 1: Program using Greater than(>) Operator

Greater than operator returns True if the first operand is greater than the second operand; otherwise, it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Example 2: Program using Less than(<) Operator

Less than operator return True if the first operand is lesser than the second; otherwise, it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Example 3: Program using Greater than(==) Operator

Equal to operator return True if the first operand is equal to the second operand; otherwise, it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Example 4: Program using Not Equal To(!=) Operator

Not equal to operator return True if the first operand is not equal to the second operand; otherwise, it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Example 5: Program using Greater than or Equal To(>=) Operator

Greater than or equal to operator returns True if the first operand is greater than or equal to the second operand; otherwise it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Example 6: Program using Less Than or Equal To(>) Operator

Less than or equal to the operator return True if the first operand is less than or equal to the second operand; otherwise, it returns False.

Refer to the example below for a better understanding:

Code:

Output:

Conclusion

  • Relational operators in python are used to compare the operand values on either side. Relational operators in python are the same in all versions of Python.
  • The Relational operators in Python return a boolean value i.e., either True or False, based on the value of operands.
  • Relational operators are used for comparing the values. The relational operators are also known as Comparison Operators. There are six relational operators in Python.
  • The Relational operators in python are: Equal To(==), Not Equal To(!=), Greater Than(>), Less Than(<), Greater Than or Equal To(>=), and Lesser Than or Equal To(<=).

Learn More:

What are Relational Operators in Python? | Scaler Topics (2024)
Top Articles
Coinbase offers zero-fee trading for $29.99 monthly subscription
Are Rope Worms Real?
Dainty Rascal Io
Celebrity Extra
Nwi Police Blotter
Tv Guide Bay Area No Cable
10 Popular Hair Growth Products Made With Dermatologist-Approved Ingredients to Shop at Amazon
Videos De Mexicanas Calientes
Paketshops | PAKET.net
Ohiohealth Esource Employee Login
Large storage units
Https //Advanceautoparts.4Myrebate.com
Immediate Action Pathfinder
Superhot Unblocked Games
Craigslist Pets Longview Tx
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Mzinchaleft
Tygodnik Polityka - Polityka.pl
Effingham Bookings Florence Sc
Mahpeople Com Login
How to Watch the Fifty Shades Trilogy and Rom-Coms
EASYfelt Plafondeiland
Dwc Qme Database
Great Clips Grandview Station Marion Reviews
Putin advierte que si se permite a Ucrania usar misiles de largo alcance, los países de la OTAN estarán en guerra con Rusia - BBC News Mundo
Mtr-18W120S150-Ul
Haunted Mansion Showtimes Near Epic Theatres Of West Volusia
Rogue Lineage Uber Titles
Dei Ebill
Synergy Grand Rapids Public Schools
Is Henry Dicarlo Leaving Ktla
Alternatieven - Acteamo - WebCatalog
Deleted app while troubleshooting recent outage, can I get my devices back?
Xemu Vs Cxbx
Best Weapons For Psyker Darktide
KITCHENAID Tilt-Head Stand Mixer Set 4.8L (Blue) + Balmuda The Pot (White) 5KSM175PSEIC | 31.33% Off | Central Online
Sabrina Scharf Net Worth
Hireright Applicant Center Login
3 bis 4 Saison-Schlafsack - hier online kaufen bei Outwell
Wilson Tire And Auto Service Gambrills Photos
Memberweb Bw
Tommy Bahama Restaurant Bar & Store The Woodlands Menu
Lyons Hr Prism Login
Booknet.com Contract Marriage 2
Sacramentocraiglist
Bonecrusher Upgrade Rs3
Lebron James Name Soundalikes
Is Chanel West Coast Pregnant Due Date
Skyward Login Wylie Isd
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
How to Find Mugshots: 11 Steps (with Pictures) - wikiHow
Att Corporate Store Location
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 6481

Rating: 4.8 / 5 (58 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.