11-if/questions/1-comparison-operators.md
==!=> CORRECT3: That's the greater operator. It checks whether an ordered value is greater than the other or not.
><=== CORRECT<3: That's the equal operator. In an expression, it checks whether a value (operand) is equal to another value (operand).
3: That's right. All the comparison operators return an untyped bool value (true or false).
>, <, >=, <=)?1-2: This is an ordered value, it can be used.
3: String is an ordered value because it's a series of numbers. So, it can be used as an operand.
4: That's right. A bool value is not an ordered value, so it cannot be used with ordering operators.
==, !=)?5: That's right. Every comparable value can be used as an operand to equality operators.
fmt.Println("go" != "go!")
fmt.Println("go" == "go!")
3-4: Watch out for the exclamation mark at the end of the second string value.
fmt.Println(1 == true)
5: That's right. A numeric constant cannot be compared to a bool value.
fmt.Println(2.9 > 2.9)
fmt.Println(2.9 <= 2.9)
fmt.Println(false >= true)
fmt.Println(true <= false)
5: That's right. Bool values are not ordered values, so they cannot be compared using the comparison operators.
package main
import "fmt"
func main() {
weight, factor := 500, 1.5
weight *= factor
fmt.Println(weight)
}
weight *= float64(factor)weight *= int(factor)weight = float64(weight) * factorweight = int(float64(weight) * factor) CORRECT1: It can be fixed.
2: Type mismatch: weight is int.
3: Lost precision: factor will be 1.
4: Type mismatch: weight is int (cannot assign back).
5: That's right. The result would be 750.