0
0
Goprogramming~10 mins

Basic data types 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 a variable of type int with value 10.

Go
var number [1] = 10
Drag options to blanks, or click blank then click option'
Aint
Bstring
Cfloat64
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using string instead of int for a number.
Using float64 when an integer is needed.
2fill in blank
medium

Complete the code to declare a variable of type bool with value true.

Go
var isActive [1] = true
Drag options to blanks, or click blank then click option'
Aint
Bfloat64
Cstring
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int or string instead of bool for true/false values.
3fill in blank
hard

Fix the error in the code by choosing the correct type for the variable.

Go
var price [1] = 19.99
Drag options to blanks, or click blank then click option'
Abool
Bstring
Cfloat64
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int for decimal numbers causes errors.
Using bool or string for numeric values.
4fill in blank
hard

Fill both blanks to create a map from string keys to int values.

Go
var scores map[[1]][2]
Drag options to blanks, or click blank then click option'
Astring
Bint
Cfloat64
Dbool
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Swapping key and value types.
Using float64 or bool for keys or values incorrectly.
5fill in blank
hard

Fill all three blanks to declare and initialize a slice of strings with three names.

Go
var names = [][1]{"[2]", "[3]", "Alice"}
Drag options to blanks, or click blank then click option'
Astring
BBob
CJohn
Dint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using int instead of string for the slice type.
Mixing up the order of names.