0
0
Goprogramming~5 mins

Relational operators in Go - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are relational operators in Go?
Relational operators compare two values and return a boolean result: true or false. They help decide if one value is equal to, greater than, or less than another.
Click to reveal answer
beginner
List the common relational operators in Go.
== (equal to), != (not equal to), < (less than), <= (less than or equal to), > (greater than), >= (greater than or equal to).
Click to reveal answer
beginner
What does the expression '5 < 10' return in Go?
It returns true because 5 is less than 10.
Click to reveal answer
intermediate
Can relational operators be used with strings in Go?
Yes, strings can be compared using relational operators like == and != to check equality or inequality. Also, < and > compare strings lexicographically (dictionary order).
Click to reveal answer
beginner
What is the result of '7 != 7' in Go?
It returns false because 7 is equal to 7, so they are not different.
Click to reveal answer
Which operator checks if two values are NOT equal in Go?
A<=
B==
C>
D!=
What does the expression '10 >= 5' evaluate to?
Afalse
Bnil
Ctrue
Derror
Which relational operator means 'less than or equal to'?
A==
B<=
C>=
D!=
Can you use relational operators to compare two strings in Go?
AYes, including == and <
BNo, only numbers can be compared
COnly == can be used
DOnly != can be used
What is the result of '3 == 4' in Go?
Afalse
Btrue
C3
D4
Explain what relational operators do in Go and give examples.
Think about how you compare numbers or words in real life.
You got /3 concepts.
    Describe how you can compare strings using relational operators in Go.
    Imagine checking if two words are the same or which comes first alphabetically.
    You got /3 concepts.