0
0
Goprogramming~10 mins

Go program structure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the package name.

Go
package [1]
Drag options to blanks, or click blank then click option'
Afunc
Bmain
Cfmt
Dimport
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 'fmt' or 'import' as package name
Forgetting the package declaration
2fill in blank
medium

Complete the code to import the standard library package for formatted I/O.

Go
import "[1]"
Drag options to blanks, or click blank then click option'
Afmt
Btime
Cmath
Dos
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 'os' or 'math' instead of 'fmt' for printing
Forgetting quotes around package name
3fill in blank
hard

Fix the error in the function declaration to define the main function.

Go
func [1]() {
    fmt.Println("Hello, Go!")
}
Drag options to blanks, or click blank then click option'
Amain
BMain
Cstart
Dfunc
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Capitalizing 'Main'
Using other function names like 'start'
4fill in blank
hard

Fill both blanks to complete the Go program that prints a message.

Go
package [1]

import "[2]"

func main() {
    fmt.Println("Welcome to Go!")
}
Drag options to blanks, or click blank then click option'
Amain
Bfmt
Cos
Dmath
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using wrong package or import names
Forgetting to import 'fmt'
5fill in blank
hard

Fill all three blanks to create a complete Go program that prints a greeting.

Go
package [1]

import "[2]"

func [3]() {
    fmt.Println("Hello, world!")
}
Drag options to blanks, or click blank then click option'
Amain
Bfmt
Dstart
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using 'start' as function name
Wrong package or import names