0
0
Goprogramming~10 mins

Why Go is widely used - Test Your Understanding

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

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

Go
package main

import "fmt"

func main() {
    fmt.[1]("Hello, Go!")
}
Drag options to blanks, or click blank then click option'
APrintfln
BPrint
CPrintf
DPrintln
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Print instead of Println which does not add a newline.
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'
Aint
Bstring
Cfloat64
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string or float64 which are not integer types.
3fill in blank
hard

Fix the error in the function signature to accept an integer parameter named 'n'.

Go
package main

func printNumber([1]) {
    // function body
}
Drag options to blanks, or click blank then click option'
Aint n
Bn: int
Cn int
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int n which is incorrect in Go.
4fill in blank
hard

Fill both blanks to create a map from string to int with one key-value pair.

Go
package main

func main() {
    m := map[[1]][2]{
        "age": 30,
    }
}
Drag options to blanks, or click blank then click option'
Astring
Bint
Cfloat64
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using float64 or bool for keys or values which is incorrect here.
5fill in blank
hard

Fill all three blanks to create a slice of integers and append 5 to it.

Go
package main

import "fmt"

func main() {
    nums := [][1]{1, 2, 3}
    nums = append(nums, [2])
    fmt.[3](nums)
}
Drag options to blanks, or click blank then click option'
Aint
B5
CPrintln
Dstring
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string instead of int for the slice type.
Forgetting to append the correct value.