Recap - Variables and Types
Part of the Fundamentals section of Coddy's GO journey — lesson 14 of 109.
Challenge
EasyIn this challenge, you'll practice working with different variable types in Go and printing them to the console.
You need to:
- Define a new integer variable named 'quantity' with value 5
- Print the product name with a label
- Print the quantity with a label
Make sure to use the variables in your print statements rather than hardcoding values where possible.
Expected output format:
Product: Coffee Mug
Quantity: 5Try it yourself
package main
import "fmt"
func main() {
// Define given variables
productName := "Coffee Mug"
// TODO: Define a new integer variable named 'quantity' with value 5
// TODO: Print the product name with a label: "Product: Coffee Mug"
// TODO: Print the quantity with a label: "Quantity: 5"
}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