Learn / Go / Variables and formatted output

Go, lesson 2 of 4

Variables and formatted output

Inside a function, := makes a variable and lets Go work out its type:

a := 3
b := 4

fmt.Printf prints with placeholders: %d for a whole number, \n for a new line.

fmt.Printf("%d + %d = %d\n", a, b, a+b)

Your turn

Print exactly 3 + 4 = 7, working out the 7 with code (not by typing it).

Press Run to see what your code prints.