Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using Print instead of Println, which does not add a new line.
Using Printline which does not exist.
โ Incorrect
The fmt.Println function prints the text followed by a new line.
2fill in blank
mediumComplete 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using Printf without format specifiers causes errors.
Using Printline which is not a valid function.
โ Incorrect
fmt.Println prints the value and adds a new line.
3fill in blank
hardFix 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using Printline which causes a compile error.
Using Print which prints without a new line.
โ Incorrect
fmt.Println correctly prints the number with a new line.
4fill in blank
hardFill 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using Printline which is not valid.
Using Println for both lines causing extra new lines.
โ Incorrect
Println prints with a new line, Print prints without a new line.
5fill in blank
hardFill 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'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using Println instead of Printf for formatted strings.
Forgetting to pass the variable to Printf.
โ Incorrect
Printf prints formatted text, name is the variable, and Println prints with a new line.