Recall & Review
beginner
What are arithmetic operators in Go?
Arithmetic operators are symbols used to perform basic math operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Click to reveal answer
beginner
What does the % operator do in Go?
The % operator gives the remainder after dividing two integers. For example, 7 % 3 equals 1 because 7 divided by 3 leaves a remainder of 1.
Click to reveal answer
intermediate
How do you perform division with floating-point numbers in Go?
To divide floating-point numbers, use variables of type float32 or float64. For example, 5.0 / 2.0 equals 2.5.
Click to reveal answer
intermediate
What happens if you divide by zero in Go?
Dividing by zero causes a runtime panic in Go. You should always check the divisor before dividing to avoid this error.
Click to reveal answer
beginner
Write a Go expression to add two variables a and b.
The expression is: a + b
Click to reveal answer
Which operator is used for multiplication in Go?
✗ Incorrect
The * symbol is used for multiplication.
What is the result of 10 % 4 in Go?
✗ Incorrect
10 divided by 4 leaves a remainder of 2, so 10 % 4 equals 2.
What type should variables be to get a decimal result when dividing in Go?
✗ Incorrect
Only float32 or float64 types can hold decimal numbers for division results.
What happens if you divide an integer by zero in Go?
✗ Incorrect
Dividing by zero causes a runtime panic error in Go.
Which operator subtracts one number from another in Go?
✗ Incorrect
The - operator subtracts numbers.
Explain the use of arithmetic operators in Go with examples.
Think about how you do basic math with numbers in Go code.
You got /6 concepts.
What precautions should you take when using division in Go?
Consider what happens if the divisor is zero or if you want decimal results.
You got /3 concepts.