0
0
Goprogramming~10 mins

Go compilation and execution flow - 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, Go!" to the console.

Go
package main

import "fmt"

func main() {
    fmt.[1]("Hello, Go!")
}
Drag options to blanks, or click blank then click option'
APrint
BPrintln
CPrintf
DPrintfln
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Print instead of Println will not add a new line.
Using Printfln is not a valid function.
2fill in blank
medium

Complete the code to declare a variable named "count" of type int with value 10.

Go
package main

func main() {
    var count [1] = 10
}
Drag options to blanks, or click blank then click option'
Astring
Bbool
Cint
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string type for a number value.
Using float64 when an integer is enough.
3fill in blank
hard

Fix the error in the code to correctly compile and run.

Go
package main

[1] "fmt"

func main() {
    fmt.Println("Go is fun!")
}
Drag options to blanks, or click blank then click option'
Aimport
Bpackage
Cfunc
Dvar
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using package instead of import.
Trying to declare fmt as a variable.
4fill in blank
hard

Fill both blanks to create a map from string to int with two entries.

Go
package main

func main() {
    scores := map[string][1]{
        "Alice": [2],
        "Bob": 90,
    }
}
Drag options to blanks, or click blank then click option'
Aint
B85
Cstring
D100
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string as value type instead of int.
Using a string value for Alice's score.
5fill in blank
hard

Fill all three blanks to define a function that returns the sum of two integers.

Go
package main

func [1](a, b [2]) [3] {
    return a + b
}
Drag options to blanks, or click blank then click option'
Aadd
Bint
Dsum
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using different types for parameters and return.
Using a function name that does not match the action.