0
0
Goprogramming~10 mins

Output using fmt.Println 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 the text "Hello, World!".

Go
package main

import "fmt"

func main() {
    fmt.[1]("Hello, World!")
}
Drag options to blanks, or click blank then click option'
APrint
BPrintline
CPrintf
DPrintln
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Print instead of Println, which does not add a new line.
Using Printline which does not exist.
2fill in blank
medium

Complete the code to print the value of variable name.

Go
package main

import "fmt"

func main() {
    name := "Alice"
    fmt.[1](name)
}
Drag options to blanks, or click blank then click option'
APrintln
BPrint
CPrintline
DPrintf
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Printf without format specifiers causes errors.
Using Printline which is not a valid function.
3fill in blank
hard

Fix the error in the code to print the number 10.

Go
package main

import "fmt"

func main() {
    num := 10
    fmt.[1](num)
}
Drag options to blanks, or click blank then click option'
APrintln
BPrintline
CPrint
DPrintf
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Printline which causes a compile error.
Using Print which prints without a new line.
4fill in blank
hard

Fill both blanks to print the message and the number on separate lines.

Go
package main

import "fmt"

func main() {
    message := "Count"
    number := 5
    fmt.[1](message)
    fmt.[2](number)
}
Drag options to blanks, or click blank then click option'
APrintln
BPrint
CPrintf
DPrintline
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Printline which is not valid.
Using Println for both lines causing extra new lines.
5fill in blank
hard

Fill all three blanks to print a formatted message with a variable.

Go
package main

import "fmt"

func main() {
    name := "Bob"
    fmt.[1]("Hello, %s!", [2])
    fmt.[3]("Goodbye!")
}
Drag options to blanks, or click blank then click option'
APrintln
Bname
CPrintf
DPrint
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using Println instead of Printf for formatted strings.
Forgetting to pass the variable to Printf.