0
0
Goprogramming~10 mins

Zero values in Go - 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 an integer variable with its zero value.

Go
var num [1]
Drag options to blanks, or click blank then click option'
Aint
Bstring
Cbool
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string type instead of int.
Using bool type which defaults to false, not zero integer.
2fill in blank
medium

Complete the code to declare a boolean variable with its zero value.

Go
var flag [1]
Drag options to blanks, or click blank then click option'
Astring
Bint
Cbool
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int type instead of bool.
Using string type which defaults to empty string, not false.
3fill in blank
hard

Fix the error in the code by completing the variable declaration with the correct zero value type.

Go
var name [1]
Drag options to blanks, or click blank then click option'
Afloat64
Bbool
Cint
Dstring
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int or bool types for string data.
Forgetting to specify the type.
4fill in blank
hard

Fill both blanks to declare a float64 variable and assign its zero value.

Go
var price [1] = [2]
Drag options to blanks, or click blank then click option'
Afloat64
B0.0
C0
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int type for floating point numbers.
Assigning zero as integer 0 instead of 0.0.
5fill in blank
hard

Fill all three blanks to declare a slice of strings with its zero value.

Go
var fruits [1] [2] [3]
Drag options to blanks, or click blank then click option'
A[]string
Bnil
C=
Dstring
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string instead of []string for slice.
Not assigning nil explicitly.
Using wrong assignment operator.