Complete the code to add 5 to variable x using an assignment operator.
package main import "fmt" func main() { x := 10 x [1] 5 fmt.Println(x) }
The += operator adds the value on the right to the variable on the left.
Complete the code to multiply variable y by 3 using an assignment operator.
package main import "fmt" func main() { y := 4 y [1] 3 fmt.Println(y) }
The *= operator multiplies the variable by the value on the right and assigns the result back.
Fix the error in the code by choosing the correct assignment operator to subtract 2 from z.
package main import "fmt" func main() { z := 15 z [1] 2 fmt.Println(z) }
The -= operator subtracts the value on the right from the variable and assigns the result back.
Fill both blanks to divide variable a by 4 and assign the result back, then print it.
package main import "fmt" func main() { a := 20 a [1] 4 fmt.[2](a) }
Printf without formatting string causes error.The /= operator divides and assigns. Println prints the value with a newline.
Fill all three blanks to create a map with keys as uppercase letters and values as their squares, only for numbers greater than 3.
package main import "fmt" func main() { nums := []int{1, 2, 3, 4, 5} squares := map[string]int{} for _, n := range nums { if n [3] 3 { squares[[1]] = [2] } } fmt.Println(squares) }
We convert number to uppercase letter by adding 64 and casting to rune then string. We square the number with n * n. We filter numbers greater than 3 with >.