go · level 1 · unit 1 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
is a list of instructions for a computer.
Code is instructions written down for a computer. A set of instructions that does one job, like a recipe for toast, is called a .
The computer follows a program exactly, starting at the top line and working down. It never guesses what you meant. It does what you wrote.
We will write our code in Go. Every Go program comes in the same frame, like a letter in an envelope. Your instructions go between the curly brackets { }. When you it, the computer starts following them.
package main
import "fmt"
func main() {
fmt.Println("Hello!")
} Press run and the computer says Hello! back, and the next lesson explains every line of the frame.
guess first
Spot the typo. What will the computer show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
package main
import "fmt"
func main() {
fmt.Println("Thank you for the lovley present!")
}
your turn
Your turn. Teach the computer a dance.
Make up a dance move and type it between the quotes on the middle line inside the curly brackets. Then press run and watch the steps appear in order.
output
press run to see what happens
fix it
The sandwich got eaten first. Can you fix it?
output
press run to see what happens
- The computer runs the lines inside the curly brackets from top to bottom. Which one happens first here?
- Eating a sandwich before it is made? Tricky. The two lines are in the wrong order.
- Swap the two lines so the Make line is on top, then press run.
nailed it
you ran your very first go program. :D
- Code is a list of instructions for a computer.
- A program runs from the top line down.
- The computer does exactly what you write, not what you meant.
new words in your collection
- code
- program
- run
This lesson isn’t saved. A free account remembers every lesson you finish.