0
0
Goprogramming~5 mins

Output using fmt.Println in Go - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does fmt.Println do in Go?
It prints the given values to the console followed by a new line, making output easy to read.
Click to reveal answer
beginner
How do you print multiple values with fmt.Println?
You separate values by commas inside fmt.Println, and it prints them with spaces in between.
Click to reveal answer
beginner
What happens if you use fmt.Println without any arguments?
It prints just a new line, moving the cursor to the next line in the console.
Click to reveal answer
beginner
Write a simple Go code snippet using fmt.Println to print "Hello, friend!"
package main

import "fmt"

func main() {
    fmt.Println("Hello, friend!")
}
Click to reveal answer
beginner
Why is fmt.Println preferred for quick output in Go programs?
Because it automatically adds spaces between values and a new line at the end, making output formatting simple.
Click to reveal answer
What does fmt.Println add automatically after printing the values?
ANo extra characters
BA new line
CA tab space
DA comma
How do you print the values 5 and 10 separated by a space using fmt.Println?
Afmt.Println(5, 10)
Bfmt.Println("5 10")
Cfmt.Println(5 + 10)
Dfmt.Println(5.10)
Which package must you import to use fmt.Println?
Afmt
Bio
Cos
Dprint
What will fmt.Println() print if called with no arguments?
AA zero
BNothing
CAn error
DJust a new line
Which of these is a correct way to print "Go is fun" using fmt.Println?
Afmt.Println(Go is fun)
Bfmt.Println('Go is fun')
Cfmt.Println("Go is fun")
Dfmt.Println(Go + is + fun)
Explain how fmt.Println works and why it is useful for output in Go.
Think about what happens when you print multiple things and how the output looks.
You got /4 concepts.
    Write a short Go program that prints your name using fmt.Println.
    Remember the basic structure of a Go program and how to print text.
    You got /4 concepts.