Log in from a computer to take this course

You'll need to log in from a computer to start Learn R. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

When writing conditional statements, sometimes we need to use different types of operators to compare values. These operators are called comparison operators.

Here is a list of some handy comparison operators and their syntax:

  • Less than: <
  • Greater than: >
  • Less than or equal to: <=
  • Greater than or equal to: >=
  • Is equal to: ==
  • Is NOT equal to: !=

Comparison operators compare the value on the left with the value on the right. For instance:

10 < 12 # Evaluates to TRUE

It can be helpful to think of comparison statements as questions. When the answer is “yes”, the statement evaluates to true, and when the answer is “no”, the statement evaluates to false. The code above would be asking: is 10 less than 12? Yes! So 10 < 12 evaluates to true.

Instructions

1.

Use a comparison operator to check if 56 is greater than or equal to 129. What should this expression evaluate to? Check by running your code!

2.

In a new line, use the right comparison operator to check if 56 is NOT equal to 129. What should this expression evaluate to? Check by running your code!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?