0
0
Goprogramming~10 mins

Output using fmt.Print 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 print "Hello, Go!" using fmt.Print.

Go
package main

import "fmt"

func main() {
    fmt.[1]("Hello, Go!")
}
Drag options to blanks, or click blank then click option'
APrintf
BPrintln
CPrint
DPrintfln
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using fmt.Println adds a new line after printing.
Using fmt.Printf requires a format string with placeholders.
2fill in blank
medium

Complete the code to print the number 42 using fmt.Print.

Go
package main

import "fmt"

func main() {
    fmt.Print([1])
}
Drag options to blanks, or click blank then click option'
A"42"
Bfmt.Println
CfortyTwo
D42
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Putting the number inside quotes prints it as a string.
Using undefined variables causes errors.
3fill in blank
hard

Fix the error in the code to print "Go is fun" using fmt.Print.

Go
package main

import "fmt"

func main() {
    fmt.Print([1])
}
Drag options to blanks, or click blank then click option'
AGo is fun
B"Go is fun"
C'Go is fun'
Dfmt.Println("Go is fun")
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using unquoted text causes a compile error.
Using single quotes for strings causes errors.
4fill in blank
hard

Fill both blanks to print "Sum: 15" using fmt.Print and addition.

Go
package main

import "fmt"

func main() {
    sum := 7 [1] 8
    fmt.Print("Sum: ", [2])
}
Drag options to blanks, or click blank then click option'
A+
B-
Csum
D15
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '-' subtracts instead of adding.
Printing the number 15 directly ignores the calculation.
5fill in blank
hard

Fill all three blanks to print "Area: 20" using fmt.Print and multiplication.

Go
package main

import "fmt"

func main() {
    length := 4
    width := [1]
    area := length [2] width
    fmt.Print("Area: ", [3])
}
Drag options to blanks, or click blank then click option'
A5
B*
Carea
D+
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using '+' adds instead of multiplying.
Printing the number 20 directly ignores the calculation.