0
0
Goprogramming~10 mins

Variable declaration using var 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 named age using var.

Go
var age [1]
Drag options to blanks, or click blank then click option'
Afloat64
Bstring
Cbool
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using a wrong type like string or bool for an integer variable.
2fill in blank
medium

Complete the code to declare a string variable named name using var.

Go
var name [1]
Drag options to blanks, or click blank then click option'
Astring
Bint
Cfloat64
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int or bool instead of string.
3fill in blank
hard

Fix the error in the variable declaration to declare a boolean variable named isActive.

Go
var isActive [1]
Drag options to blanks, or click blank then click option'
Abool
Bstring
Cint
Dfloat64
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string or int instead of bool.
4fill in blank
hard

Fill both blanks to declare a float variable named price and assign it the value 9.99.

Go
var price [1] = [2]
Drag options to blanks, or click blank then click option'
Afloat64
B9.99
Cint
Dtrue
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int type for decimal numbers.
Assigning a boolean value instead of a number.
5fill in blank
hard

Fill all three blanks to declare a variable named count of type int and assign it the value 10.

Go
var [1] [2] = [3]
Drag options to blanks, or click blank then click option'
Acount
Bfloat64
C10
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using the wrong variable name or type.
Assigning a float value to an int variable.