Getting Started

Python - IntroductionPython - Hello World ProgramPython - SyntaxPython - Data TypesPython - Variables

Operators

Python - Arithmetic OperatorsPython - Relational OperatorsPython - Logical OperatorsPython - Assignment OperatorsPython - Bitwise OperatorsPython - Membership OperatorsPython - Identity OperatorsPython - Increment and Decrement Operators

Conditions

Python - If Else statement

Loop

Python - While LoopPython - For Loop

Numbers

Python - NumbersPython - Number Conversion

Strings

Python - StringsPython - String OperatorsPython - String FormattingPython - String MethodsPython - String Format Method

List

Python - ListPython - List Methods

Tuple

Python - Tuple

Set

Python - SetPython - Set Methods

Dictionary

Python - DictionaryPython - Dictionary Methods

Functions

Python - FunctionsPython - Functions - Variable length argumentsPython - Lambda Function

Scope of Variables

Python - Scope of Variables

Modules

Python - ModulesPython - Math ModulePython - JSON ModulePython - datetime ModulePython - time Module

I/O

Python - Read input from keyboard

File

Python - File Handling

Exception Handling

Python - Exception Handling

OOP

Python - Classes and ObjectsPython - Class Constructor __init__ methodPython - Class Destructor __del__ methodPython - Built-in Class AttributesPython - InheritancePython - Method OverridingPython - Method Overloading

Package Management

Python - PIP

Python - MySQL

Python - MySQL - Getting StartedPython - MySQL - Insert dataPython - MySQL - Select dataPython - MySQL - Update dataPython - MySQL - Delete data

Python - CSV

Python - Read data from CSV filePython - Write data in CSV file

Python - Relational Operators

Python

python logo

In this tutorial we will learn about Relational operators in Python.

We use relational operators to compare values. The result is in boolean form.

Following are the list of Relational operators in Python

Equals

We use the == sign to find if two values are equal.

In the following Python program we are checking equality of two values.

# variables
x = 10
y = 10

# operation
result = x == y

# output
print("Result:", result)

The above code will give the following result.

Result: True

Not equals

We use the != sign to find if two values are not equal.

In the following Python program we are checking whether two values are not equal.

# variables
x = 10
y = 20

# operation
result = x != y

# output
print("Result:", result)

The above code will give the following result.

Result: True

Greater than

We use the > sign to find if left side value is greater than the right side value.

In the following Python program we are checking whether x is greater than y.

# variables
x = 20
y = 10

# operation
result = x > y

# output
print("Result:", result)

The above code will give the following result.

Result: True

Less than

We use the < sign to find if left side value is less than the right side value.

In the following Python program we are checking whether x is less than y.

# variables
x = 10
y = 20

# operation
result = x < y

# output
print("Result:", result)

The above code will give the following result.

Result: True

Greater than or equal to

We use the >= sign to find if left side value is greater than or equal to the right side value.

In the following Python program we are checking whether x is greater than or equal to y.

# variables
x = 20
y = 10

# operation
result = x >= y

# output
print("Result:", result)

The above code will give the following result.

Result: True

Less than or equal to

We use the <= sign to find if left side value is less than or equal to the right side value.

In the following Python program we are checking whether x is less than or equal to y.

# variables
x = 10
y = 20

# operation
result = x <= y

# output
print("Result:", result)

The above code will give the following result.

Result: True