Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using string type instead of int.
Using bool type which defaults to false, not zero integer.
โ Incorrect
In Go, declaring a variable with type int without initialization sets it to zero value 0.
2fill in blank
mediumComplete 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using int type instead of bool.
Using string type which defaults to empty string, not false.
โ Incorrect
Boolean variables in Go default to false as their zero value.
3fill in blank
hardFix 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using int or bool types for string data.
Forgetting to specify the type.
โ Incorrect
Strings in Go default to an empty string "" as their zero value.
4fill in blank
hardFill 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using int type for floating point numbers.
Assigning zero as integer 0 instead of 0.0.
โ Incorrect
Float64 variables use type float64 and their zero value is 0.0.
5fill in blank
hardFill 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
string instead of []string for slice.Not assigning
nil explicitly.Using wrong assignment operator.
โ Incorrect
A slice of strings is declared as []string. Its zero value is nil, assigned with =.