Learn

Now that we know a bit about different operators, let’s try writing our own expressions!

As we’ve seen, we can use operators to change something’s value, add other things to our program, to take them away, or to perform calculations. We can also use operators to compare statements or determine whether they are true or false.

One important thing about operators when you program is that they may look different from language to language. That’s because different programming languages have different syntax, or rules for how they are written.

Instructions

Let’s use the operators that we’ve learned to add different fruits to the screen and determine their relationships.

  • Create a variable named orange and set it equal to 4.

  • Decrease the number of oranges from 4 to 2. Save the result to the orange variable again.

  • Run the code and see how many oranges appear on the screen.

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?