GCGrowCarrer

Operators and Expressions

Locked

Lesson 2 of 60 · Syntax · Easy

Finish these first:Variables and Types →Or pass the tests below to unlock it now.

1

The big idea

Operators let Python do math and compare values, just like a calculator. You can calculate an answer on the right side of = and save it straight into a variable: Python works out the math on the right side first, then stores the answer in the variable on the left.

Think of it like this: Think of operators like the buttons on a pocket calculator: `+`, `-`, `*`, and `/` combine numbers into a fresh answer.
Key words (tap to learn):
2

Read the lesson

Operators let Python do math and compare values, just like a calculator.

You can calculate an answer on the right side of = and save it straight into a variable:

apples = 3 + 5     # 8 (addition)
change = 10 - 4    # 6 (subtraction)
area = 3 * 4       # 12 (multiplication)
half = 10 / 2      # 5.0 (division)

Python works out the math on the right side first, then stores the answer in the variable on the left.

You can also compare numbers with == (equal), < (less than), and > (greater than), which give True or False.

3

Quick check

What value is stored in `points` after running `points = 3 + 5`?

4

Your challenge

2 sample tests, 1 hidden

Create a variable named total that adds 4 and 6 (type total = 4 + 6).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to java.operators (90% overlap). `/` is true division in Python but integer division on ints in Java; use `//` vs `/`.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Operators and Expressions.

Mastery0%