Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a variable named age with value 30.
Go
var age [1] = 30
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
string type for a number.Forgetting to specify the type.
โ Incorrect
In Go, int is used to declare integer variables like age which holds whole numbers.
2fill in blank
mediumComplete the code to assign the value 100 to the variable score.
Go
var score int score [1] 100
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
== instead of = for assignment.Using
:= when variable is already declared.โ Incorrect
The single equals sign = is used to assign a value to a variable in Go.
3fill in blank
hardFix the error in the code to declare and assign variable name with value "Alice".
Go
var name [1] = "Alice"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using numeric types for text variables.
Omitting the type declaration.
โ Incorrect
The variable name holds text, so its type must be string.
4fill in blank
hardFill both blanks to declare a variable height of type float64 and assign it the value 1.75.
Go
var height [1] [2] 1.75
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
int type for decimal numbers.Using
:= when variable is declared with var.โ Incorrect
Use float64 for decimal numbers and = to assign the value.
5fill in blank
hardFill all three blanks to declare and assign a variable isActive of type bool with value true.
Go
var [1] [2] [3] true
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using
int type for boolean values.Forgetting to assign a value.
โ Incorrect
Declare the variable name isActive, type bool, and assign it true using =.