Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print "Hello, Go!" using fmt.Print.
Go
package main import "fmt" func main() { fmt.[1]("Hello, Go!") }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using fmt.Println adds a new line after printing.
Using fmt.Printf requires a format string with placeholders.
โ Incorrect
The fmt.Print function prints the text exactly as given without adding a new line.
2fill in blank
mediumComplete the code to print the number 42 using fmt.Print.
Go
package main import "fmt" func main() { fmt.Print([1]) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Putting the number inside quotes prints it as a string.
Using undefined variables causes errors.
โ Incorrect
To print the number 42, pass the number directly without quotes to fmt.Print.
3fill in blank
hardFix the error in the code to print "Go is fun" using fmt.Print.
Go
package main import "fmt" func main() { fmt.Print([1]) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using unquoted text causes a compile error.
Using single quotes for strings causes errors.
โ Incorrect
Strings in Go must be inside double quotes. Single quotes are for single characters.
4fill in blank
hardFill both blanks to print "Sum: 15" using fmt.Print and addition.
Go
package main import "fmt" func main() { sum := 7 [1] 8 fmt.Print("Sum: ", [2]) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using '-' subtracts instead of adding.
Printing the number 15 directly ignores the calculation.
โ Incorrect
The sum is calculated by adding 7 and 8 with '+'. Then print the variable sum.
5fill in blank
hardFill all three blanks to print "Area: 20" using fmt.Print and multiplication.
Go
package main import "fmt" func main() { length := 4 width := [1] area := length [2] width fmt.Print("Area: ", [3]) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using '+' adds instead of multiplying.
Printing the number 20 directly ignores the calculation.
โ Incorrect
Width is 5, multiply length and width with '*', then print the variable area.