Lesson 8 of 38 · Fundamentals
Quiz: Go Basics
You have explored the whole first island: the structure of a Go program, variables declared with var and :=, types and zero values, constants and arithmetic, strings and formatting verbs, decisions with if and switch, and Go's one and only loop, for.
Answer these six questions to lock in the fundamentals before you face the chapter boss. Read every explanation — even for the questions you get right — because each one highlights a detail that trips up developers coming from other languages.
What this quiz covers
The questions check what you learned in the Fundamentals chapter of Learn Go. Not sure about a topic? Review its lesson first:
- Go Hello World: Your First Go Program
Write your first Go program: package main, import fmt and print with fmt.Println. Learn how a Go program is structured — it runs right in your browser.
- Go Variables: var, := and Multiple Assignment
Declare Go variables with var and the short := syntax, assign several values at once, swap them in one line and see why unused variables don't compile.
- Go Data Types and Zero Values
Learn Go's basic types — int, float64, string, bool, byte and rune — type conversions, and the zero value every Go variable starts with.
- Go Constants and Arithmetic Operators
Use Go constants and iota, arithmetic operators, integer division and remainder, += and ++, and the math package: Sqrt, Pow, Round and Pi.
- Go Strings and fmt.Sprintf Formatting
Learn how Go strings work — bytes, len, indexing and slicing — use the strings package and strconv.Itoa, and format text with fmt.Sprintf verbs.
- Go if/else and switch Statements
Make decisions in Go with if, else if and else, comparison and logical operators, if with a short statement, and switch cases that never fall through.
- Go for Loops: The Only Loop You Need
Master the Go for loop: three-part loops, while-style and infinite loops, break and continue, nested loops and range over strings and integers.
Keep learning
Need a quick reminder? The Go cheat sheet has every topic of Learn Go on one page.
Lesson last updated on .