Complete the code to print "Hello, Go!" using fmt.Print.
package main import "fmt" func main() { fmt.[1]("Hello, Go!") }
The fmt.Print function prints the text exactly as given without adding a new line.
Complete the code to print the number 42 using fmt.Print.
package main import "fmt" func main() { fmt.Print([1]) }
To print the number 42, pass the number directly without quotes to fmt.Print.
Fix the error in the code to print "Go is fun" using fmt.Print.
package main import "fmt" func main() { fmt.Print([1]) }
Strings in Go must be inside double quotes. Single quotes are for single characters.
Fill both blanks to print "Sum: 15" using fmt.Print and addition.
package main import "fmt" func main() { sum := 7 [1] 8 fmt.Print("Sum: ", [2]) }
The sum is calculated by adding 7 and 8 with '+'. Then print the variable sum.
Fill all three blanks to print "Area: 20" using fmt.Print and multiplication.
package main import "fmt" func main() { length := 4 width := [1] area := length [2] width fmt.Print("Area: ", [3]) }
Width is 5, multiply length and width with '*', then print the variable area.
