In-Class Go Exercise 2

Exercise · Explain This Go Loop (Usernames)

Go · Beginner
Explain this Go program out loud like you're presenting code to a team. Focus on the slice, the loop, and what gets printed to the console.
package main

import "fmt"

func main() {

	users := []string{
		"alice",
		"bob",
		"charlie",
	}

	for _, user := range users {
		fmt.Println(user)
	}

}
🎯 Instructions oral task
  1. Explain what the program does.
  2. Describe what a slice is.
  3. Explain what is stored inside the users slice.
  4. Explain how the for loop works.
  5. Describe what range does.
  6. Explain what gets printed to the console.
📖 Vocabulary core
  • slice — dynamic collection of values in Go.
  • loop — structure used to repeat code.
  • iterate — go through items one by one.
  • element — single item inside a collection.
  • range — keyword used to loop through collections.
  • console output — text displayed in the terminal.
  • variable — named container for storing data.
🧩 Collocations natural English
  • store values in a slice
  • loop through the data
  • print each username
  • iterate over a collection
  • access each element
  • display the output
🗣️ Phrasal Verbs interview speech
  • loop through — “The program loops through the slice.”
  • print out — “The application prints out each username.”
  • go through — “The loop goes through all elements.”
  • set up — “We set up a slice of usernames.”
💬 Useful Interview Phrases communication
  • “This program demonstrates how to...”
  • “The slice contains multiple string values.”
  • “The loop iterates over each element.”
  • “The range keyword is used to...”
  • “For every iteration, the program prints...”
  • “This is useful when working with collections of data.”
🎤 Model Answer spoken

This Go program demonstrates how to use a loop with a slice. First, the program creates a slice called users. The slice stores three string values: alice, bob, and charlie.

After that, the program uses a for loop together with the range keyword. The range keyword allows the program to iterate over each element inside the slice.

During every iteration, the current username is stored inside the variable called user. Then the program uses fmt.Println() to print the username to the console.

As a result, the program prints each username on a separate line. This type of loop is commonly used when processing lists of users or data collections in Go applications.