0
0
Goprogramming~10 mins

Constants 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 constant named Pi with the value 3.14.

Go
const Pi [1] 3.14
Drag options to blanks, or click blank then click option'
A=
B:=
C==
D:
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using := instead of = for constants
Using == which is a comparison operator
2fill in blank
medium

Complete the code to declare multiple constants Pi and E with values 3.14 and 2.71.

Go
const (
    Pi [1] 3.14
    E  [1] 2.71
)
Drag options to blanks, or click blank then click option'
A:=
B==
C=
D:
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using := inside const blocks
Using : instead of =
3fill in blank
hard

Fix the error in the constant declaration to assign the value 100 to MaxScore.

Go
const MaxScore [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 =
Using == which causes syntax errors
4fill in blank
hard

Fill both blanks to declare constants Width and Height with values 1920 and 1080.

Go
const Width [1] 1920
const Height [2] 1080
Drag options to blanks, or click blank then click option'
A=
B:=
C==
D:
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using := for constants
Using : or == instead of =
5fill in blank
hard

Fill all three blanks to declare constants Name, Age, and Active with values "Alice", 30, and true.

Go
const Name [1] "Alice"
const Age [2] 30
const Active [3] true
Drag options to blanks, or click blank then click option'
A=
B:=
C==
D:
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using := for constants
Using == or : instead of =