Challenge - 5 Problems
Go Beginner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ Predict Output
intermediateOutput of a simple Go program
What is the output of this Go program?
Go
package main import "fmt" func main() { fmt.Println("Hello, Go!") }
Attempts:
2 left
๐ก Hint
Look carefully at the exact string inside fmt.Println.
โ Incorrect
The program prints exactly what is inside the quotes, including capitalization and punctuation.
๐ง Conceptual
intermediatePurpose of the main function in Go
What is the role of the main function in a Go program?
Attempts:
2 left
๐ก Hint
Think about where the computer starts running your code.
โ Incorrect
In Go, the main function is where the program starts running. Without it, the program has no entry point.
๐ง Debug
advancedIdentify the error in this Go program
What error will this Go program produce when run?
Go
package main import "fmt" func main() { fmt.Println("Welcome to Go") fmt.Println("Let's learn") fmt.Println("Go is fun") }
Attempts:
2 left
๐ก Hint
Check the parentheses in the last fmt.Println line.
โ Incorrect
The last fmt.Println call is missing a closing parenthesis, causing a syntax error.
๐ Syntax
advancedCorrect way to import and use fmt package
Which option shows the correct way to import the fmt package and print "Go Rocks"?
Attempts:
2 left
๐ก Hint
Remember how Go imports packages with quotes.
โ Incorrect
Go imports packages using import "packageName" syntax. Parentheses are used for multiple imports.
๐ Application
expertOutput of a Go program with variable and fmt.Printf
What is the output of this Go program?
Go
package main import "fmt" func main() { name := "Go Learner" age := 3 fmt.Printf("%s is %d years old.\n", name, age) }
Attempts:
2 left
๐ก Hint
Look at how fmt.Printf formats strings with %s and %d.
โ Incorrect
fmt.Printf replaces %s with the string variable and %d with the integer variable in order.
