Python language basics 9: relational operators

Exercises in .NET with Andras Nemes

Introduction

In the previous post we looked at how to assign nulls to a variable using the None keyword. In this post we’ll look at Python’s relational operators. These are operators that help us compare two values.

Those of you who have experience with other object-oriented languages like C# or Java can safely skip this post. The relational operators are the same in Python: ==, !=, ,=.

Relational operators

You’ll be familiar with most of them from the maths classes:

  • == : is equal to
  • != : is not equal to
  • < : less than
  • > : more than
  • <= : less than or equal to
  • >= : greater than or equal to

The first two may look strange at first. We’ve already seen the operator that most people recognise as equality: ‘=’. However, we didn’t use it to compare two values but to assign a value to an operator…

View original post 163 more words

Advertisements
This entry was posted in Brian By Experience. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s