Recap - Making Comparisons
Part of the Fundamentals section of Coddy's GO journey — lesson 28 of 109.
Challenge
EasyComplete the code to evaluate different comparison and logical expressions and print the results.
Try it yourself
package main
import "fmt"
func main() {
// Given variables
age := 25
score := 85
isPremium := true
// TODO: Create a boolean variable named 'isAdult' that checks if age is greater than or equal to 18
// TODO: Create a boolean variable named 'isPassing' that checks if score is greater than or equal to 70
// TODO: Create a boolean variable named 'isEligible' that checks if the person is both an adult AND has premium status
// TODO: Create a boolean variable named 'needsImprovement' that checks if the score is less than 70 OR age is less than 20
// TODO: Create a boolean variable named 'isRejected' that is the NEGATION (opposite) of isPassing
// Print results
fmt.Println("Is Adult:", isAdult)
fmt.Println("Is Passing:", isPassing)
fmt.Println("Is Eligible:", isEligible)
fmt.Println("Needs Improvement:", needsImprovement)
fmt.Println("Is Rejected:", isRejected)
}All lessons in Fundamentals
4Comparison & Logical Operators
Comparison Operators - Part 1Comparison Operators - Part 2Logical AND OperatorLogical OR OperatorLogical NOT OperatorOperator Precedence BasicsRecap - Making Comparisons7Control Flow: Loops
What The `for` Loop ExplainedFor Loop - BasicFor Loop - Condition OnlyThe `break` KeywordThe `continue` KeywordNested LoopsRecap - Repeating Actions2Variables and Basic Data Types
What is a variableType Inference with `:=`Integers (int)Floating-Point NumbersBooleansStringsZero ValuesConstantsNaming ConventionsRecap - Variables and Types5Basic Input/Output
Formatted OutputFormat VerbsPrinting TypesGetting Basic User InputRecap - Input and Output8Functions
Understanding FunctionsDeclaring a FunctionCalling FunctionsFunction ParametersReturning a Single ValueReturning Multiple ValuesNamed Return ValuesFunction Scope BasicsRecap - Creating Reusable Code3Basic Operators
Arithmetic OperatorsDivision OperatorThe Modulo OperatorAssignment OperatorAugmented Assignment OperatorsIncrement and DecrementRecap - Calculations6Control Flow: Conditionals
The `if` StatementThe `else` KeywordThe `else if` KeywordVariable Shadowing in `if`Initializing VariablesThe `switch` StatementSwitch with ExpressionsSwitch without ExpressionThe `fallthrough` KeywordRecap - Making Decisions