Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    15 Quizzes
  2. Python: Control Flow
    12 Quizzes
  3. Python: Errors
    5 Quizzes
Lesson 2, Topic 5
In Progress

Python: Relational Operators

Yasin Cakal 11 Oct 2021
Lesson Progress
0% Complete

Now that we’ve added if statements to our repertoire for developing control flow, let’s look at some additional techniques for creating boolean expressions. While we have discussed two relational operators thus far, equals and not equals, there are four more:

  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to

Let’s take a look at an example that shows how this could be used to determine if a student has passed the class or not:

grade = 75

if grade >= 65:
    print("You passed the class!") # This will print.
if grade < 65:
    print("See you in summer school!") # This will not.

Notice that it would be mathematically impossible for both print statements to execute at the same time.

%d bloggers like this: