Operators and Comparisons
LockedLesson 2 of 25 · Syntax · Easy
Finish these first:Variables and Primitive Types →Or pass the tests below to unlock it now.
The big idea
Operators let Go do arithmetic and compare values right inside your code. Go works out the math on the right side of := 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.
Think of it like this: Think of Go operators (`+`, `-`, `*`, `/`) like calculator buttons that calculate the right side first and store the answer in your variable.
Read the lesson
Operators let Go do arithmetic and compare values right inside your code.
Go works out the math on the right side of := first, then stores the answer in the variable on the left:
apples := 3 + 5 // 8
change := 10 - 4 // 6
area := 3 * 4 // 12
half := 10 / 2 // 5
You can also compare numbers with == (equal), < (less than), and > (greater than), which give true or false.
Quick check
What value does `sum := 3 + 5` store in `sum`?
Your challenge
Inside main(), create a variable named total that adds 4 and 6 (type total := 4 + 6).
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
Similar to python.operators (90% overlap). Arithmetic and boolean operators behave identically; watch === in JS and integer division in C++/Go/Rust/Java.
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Operators and Comparisons.