0
0
Goprogramming~10 mins

Writing first Go program - Interactive Code Practice

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

Complete the code to print "Hello, World!" in Go.

Go
package main

import "fmt"

func main() {
    fmt.[1]("Hello, World!")
}
Drag options to blanks, or click blank then click option'
APrintln
BPrint
CPrintf
DPrintfln
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using fmt.Print does not add a new line after printing.
Typo in function name like Printfln causes errors.
2fill in blank
medium

Complete the code to declare the main package in Go.

Go
[1] main

func main() {
    // program starts here
}
Drag options to blanks, or click blank then click option'
Afunc
Bmain
Cimport
Dpackage
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Writing 'func' instead of 'package' at the top.
Omitting the package declaration causes errors.
3fill in blank
hard

Fix the error in the function declaration to make it valid Go code.

Go
func [1]() {
    fmt.Println("Hello")
}
Drag options to blanks, or click blank then click option'
Amain
BMain
Cmain()
Dfunc
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using uppercase 'Main' instead of 'main'.
Adding parentheses after the function name in declaration.
4fill in blank
hard

Fill both blanks to import the fmt package and print a message.

Go
package main

import [1]"fmt"[2]

func main() {
    fmt.Println("Welcome to Go!")
}
Drag options to blanks, or click blank then click option'
A(
B"
C)
D[
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using square brackets instead of parentheses.
Using quotes alone without parentheses for multiple imports.
5fill in blank
hard

Fill all three blanks to create a map of string keys to int values with one entry.

Go
package main

func main() {
    scores := map[[1]][2]{
        "Alice": [3],
    }
}
Drag options to blanks, or click blank then click option'
Astring
Bint
C100
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using float64 instead of int for map values.
Using incorrect key type like int instead of string.