Top 10 Programming Languages to Learn in 2019

Programming

Python Comparision Operators – Python Basics

python-programming-670x335

Comparison Operators in python are pretty straight forward if you have any sort of background in Mathematics.

First we’ll present a table of comparison operators and then work through some examples:

OperatorDescriptionExmple
==if two values of the operands are equal,
then the condition becomes true
‘1’ == ‘1’ is true
!=if two values of the operands are not equal,
then condition becomes true
‘1’ != ‘2’ is true
>If the value of the left operand is greater
than the value of the right operand,
then the condition becomes true.
2 > 1 is true
<If the value of the right operand is greater
than the value of the left operand,
then the condition becomes true.
2 < 1 is false
>=If the value of the left operand is greater
or equal to the value of the right operand,
then the condition becomes true.
2 >= 1 is true
<=If the value of the right operand is greater
or equal to the value of the left operand,
then the condition becomes true.
2 <= 1 is false

Examples

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 1 <= 2
True
>>> 2 >= 3
False
>>> 1 == 1
True
>>> 'a' == 1
False
>>> type('a') == str
True
>>> 
Related posts
Programming

Amazon Price Scraper and Auto Mailer Python App

ProgrammingPython

Top 10 Deep Learning frameworks in 2019 (with comparison)

ProgrammingPython

Python vs R - Data Visualization

Programming

Cython vs Python - Speed up your Python

Leave a Reply

Your email address will not be published. Required fields are marked *

Improve Your Python

...with a fresh 🐍 Python Trick 💌
code snippet every couple of days:
You can also contribute to PyBlog
Visit Contribute to Community

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

PyBlog will use the information you provide on this form to be in touch with you and to provide updates and marketing.