Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print numbers from 1 to 3 using a loop.
Go
for i := 1; i <= [1]; i++ { fmt.Println(i) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using 0 or 10 instead of 3 in the loop condition.
Forgetting to use <= instead of <.
โ Incorrect
The loop should run from 1 to 3, so the condition is i <= 3.
2fill in blank
mediumComplete the code to print a 3x3 grid of stars using nested loops.
Go
for i := 0; i < 3; i++ { for j := 0; j < [1]; j++ { fmt.Print("*") } fmt.Println() }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using a different number than 3 for the inner loop.
Using <= instead of < causing extra stars.
โ Incorrect
Both loops should run 3 times to create a 3x3 grid.
3fill in blank
hardFix the error in the nested loops to print numbers 1 to 3 in each row.
Go
for i := 1; i <= 3; i++ { for j := 1; j <= [1]; j++ { fmt.Print(j, " ") } fmt.Println() }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using 5 or 4 causing extra numbers.
Using 0 causing no output.
โ Incorrect
The inner loop should run from 1 to 3 to print numbers 1, 2, 3 in each row.
4fill in blank
hardFill both blanks to create a multiplication table from 1 to 3.
Go
for i := 1; i <= [1]; i++ { for j := 1; j <= [2]; j++ { fmt.Printf("%d ", i*j) } fmt.Println() }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using different numbers for the two loops.
Using numbers larger than 3 causing bigger tables.
โ Incorrect
Both loops should run from 1 to 3 to create a 3x3 multiplication table.
5fill in blank
hardFill all three blanks to print a right triangle of stars with 3 rows.
Go
for i := 1; i <= [1]; i++ { for j := 1; j <= [2]; j++ { if j <= [3] { fmt.Print("*") } } fmt.Println() }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
j instead of i in the if condition.Using wrong loop limits causing incorrect triangle size.
โ Incorrect
The outer and inner loops run 3 times. The if condition prints stars up to the current row number i.