Question | Click to View Answer |
What does the following code print to the console? if 2 == 2 {
fmt.Println("ice cream is tasty!")
}
|
The code block in an |
What does the following code print to the console? if "cat" == "dog" {
fmt.Println("prrrr")
} else {
fmt.Println("ruff")
}
|
The boolean condition ( |
What does the following code print to the console? if 5 > 10 {
fmt.Println("fan")
} else if 8 != 9 {
fmt.Println("glass")
} else {
fmt.Println("cream")
}
|
If the boolean condition associated with the |
What does the following code print to the console? name := "maria"
if name == "melissa" {
fmt.Println("usa")
} else if name == "mary" {
fmt.Println("ireland")
} else {
fmt.Println("colombia")
}
|
If the boolean conditions associated with |
What does the following code print to the console? if 88 > 100 {
fmt.Println("cardio")
}
|
Nothing is printed. The boolean condition ( |
What does the following code print to the console? hairColor := "blue"
if 3 > 2 {
if hairColor == "black" {
fmt.Println("You rock!")
} else {
fmt.Println("Boring")
}
}
|
This is an example of a nested The boolean condition for the inner |
What does the following code print to the console? if true {
fmt.Println(101)
} else {
fmt.Println(202)
}
|
In previous examples, we've used boolean expressions that evaluate to |
What does the following code print to the console? if false {
fmt.Println("Nissan")
} else if true {
fmt.Println("Ford")
} else if true {
fmt.Println("BMW")
} else {
fmt.Println("Audi")
}
|
"Ford" is printed. The first |
What does the following code print to the console? var likesHugs bool
if likesHugs {
fmt.Println("Hug me!")
} else {
fmt.Println("High 5 is better")
}
|
The |
What does the following code print to the console? i := 2
switch i {
case 0:
fmt.Println("Zero")
case 1:
fmt.Println("One")
case 2:
fmt.Println("Two")
case 3:
fmt.Println("Three")
default:
fmt.Println("Whatever")
}
|
i := 2
if i == 0 {
fmt.Println("Zero")
} else if i == 1 {
fmt.Println("One")
} else if i == 2 {
fmt.Println("Two")
} else if i == 3 {
fmt.Println("Three")
} else {
fmt.Println("Whatever")
}
|