0
0
Goprogramming~5 mins

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

Choose your learning style9 modes available
Recall & Review
beginner
What does fmt.Print do in Go?

fmt.Print prints text to the standard output (usually the screen) without adding a new line at the end.

Click to reveal answer
beginner
How is fmt.Print different from fmt.Println?

fmt.Print prints text as is, while fmt.Println adds a new line after printing.

Click to reveal answer
beginner
Write a simple Go code snippet using fmt.Print to print "Hello, Go!".
<pre>package main
import "fmt"

func main() {
    fmt.Print("Hello, Go!")
}</pre>
Click to reveal answer
intermediate
Can fmt.Print print multiple values? How?

Yes, you can pass multiple values separated by commas. fmt.Print prints them without adding spaces.

Click to reveal answer
beginner
What will be the output of this code?<br>
fmt.Print("Go", "Lang")

The output will be GoLang because fmt.Print prints multiple values without adding spaces.

Click to reveal answer
What does fmt.Print("Hi") do?
APrints 'Hi' without a new line
BPrints 'Hi' with a new line
CPrints nothing
DCauses an error
Which function adds a new line after printing in Go?
Afmt.Print
Bfmt.Println
Cfmt.Printf
Dfmt.Scan
What will fmt.Print("Go", "Lang") output?
AGo Lang
BError
CGo,Lang
DGoLang
How do you print a number and a string together using fmt.Print?
Afmt.Print(5, " apples")
Bfmt.Print(5 + " apples")
Cfmt.Print("5 apples")
Dfmt.Print(5 & " apples")
Which package must you import to use fmt.Print?
Aos
Bmath
Cfmt
Dio
Explain how fmt.Print works and how it differs from fmt.Println.
Think about what happens after the text is printed.
You got /4 concepts.
    Write a Go program snippet that prints your name and age using fmt.Print.
    Use commas to separate values inside fmt.Print.
    You got /4 concepts.