{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Comparison Operators \n", "\n", "In this lecture we will be learning about Comparison Operators in Python. These operators will allow us to compare variables and output a Boolean value (True or False). \n", "\n", "If you have any sort of background in Math, these operators should be very straight forward.\n", "\n", "First we'll present a table of the comparison operators and then work through some examples:\n", "\n", "## Table of Comparison Operators\n", "\n", "
Operator | Description | Example | \n", "
---|---|---|
== | \n", "If the values of two operands are equal, then the condition becomes true. | \n", "(a == b) is not true. | \n", "
!= | \n", "If values of two operands are not equal, then condition becomes true. | \n", "(a != b) is true | \n", "
<> | \n", "If values of two operands are not equal, then condition becomes true. | \n", "(a <> b) is true. This is similar to != operator. | \n", "
> | \n", "If the value of left operand is greater than the value of right operand, then condition becomes true. | \n", "(a > b) is not true. | \n", "
< | \n", "If the value of left operand is less than the value of right operand, then condition becomes true. | \n", "(a < b) is true. | \n", "
>= | \n", "If the value of left operand is greater than or equal to the value of right operand, then condition becomes true. | \n", "(a >= b) is not true. | \n", "
<= | \n", "If the value of left operand is less than or equal to the value of right operand, then condition becomes true. | \n", "(a <= b) is true. | \n", "