Go course

LoopsQuiz: Loops

Go

Display

Theme

Loops · Quiz

Quiz: Loops

Test your understanding of the different forms of for, break, continue, range over integers, and looping over strings.

  1. Question 1 of 6Which loop keywords does Go have?
  2. Question 2 of 6What does the following code print?
    for i := range 4 {
    	fmt.Print(i)
    }
  3. Question 3 of 6What does the following code print?
    for i := 1; i <= 6; i++ {
    	if i%2 == 0 {
    		continue
    	}
    	if i == 5 {
    		break
    	}
    	fmt.Print(i, " ")
    }
  4. Question 4 of 6What is the output of len("café")?
  5. Question 5 of 6In for i, r := range "aé☕", which values of i are produced?
  6. Question 6 of 6How do you write a loop that runs as long as saldo > 0?