0
0
Goprogramming~10 mins

Why variables are needed in Go - Test Your Understanding

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

Complete 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'
Abool
Bstring
Cint
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string type for a number.
Forgetting to specify the type.
2fill in blank
medium

Complete 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'
A=
B==
C:=
D!=
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using == instead of = for assignment.
Using := when variable is already declared.
3fill in blank
hard

Fix 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'
Aint
Bfloat64
Cbool
Dstring
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using numeric types for text variables.
Omitting the type declaration.
4fill in blank
hard

Fill 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'
Afloat64
B=
C:=
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int type for decimal numbers.
Using := when variable is declared with var.
5fill in blank
hard

Fill 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'
AisActive
Bbool
C=
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int type for boolean values.
Forgetting to assign a value.