Back

Relational operators - Answers

Q1. What do the following symbols mean?

Symbol Meaning
> Greater than 
>= Greater than or equal to 
<  Less than
<=  Less than or equal to
!=  Not equal to
==  Equal to
=  Assignment (NOTHING to do with relational operators!)

Q2. Predict the answers!

Expression True or False?
 4 > 10 False
 6 < 19 True 
 30 != 30 30 != 30
 9.2 = 45 Error - using the assign symbol
 23 <= 23 True 
 100 == 100 True 
 32 <= 23 False 
 3 = 3 Error - using the assign symbol 
 32 >= 99 False
 99 >= 88 True
 34 < 20 False
 20 < 40 True 
 56 != 20 True 
 30 == 20  False
 55 != 55  False

Q3. Compare answers to a friend's answers then use Python.

Q4. Evaluate the following expressions:

Expression True of False?
'fred' == 'fred' True 
'Bell' >= 'Bill' False 
'Rhino' != 'elephant' True 
Jack != John  Error - strings not in quotes
'massive' > 'greater' True 
'Dog' == 'Dogs'  False
'smash and grab' > 'smashing' False 
'Mars' < 'Mars Bar'  True
Bee < Honey Error - strings not in quotes 
'shirt' > 'shirt and tie'  False
'**#?' > '%##?' True
'' > '    ' False 
'$20' >= 'Twenty dollars' False 
'My house' != 'Your house' True 
'cat' = 'cat' Error - assignment symbol used

Q5. Compare answers to a friend's answers then use Python. It is useful to ask students to memorise a few key things about the ASCII table and test them on it:

null = 0
space = 32
0 = 48
A = 65
a = 97
del = 127

The ASCII table is (roughly) organised: CONTROL CHARACTERS > PUNCTUATION > NUMBERS > CAPITAL LETTERS > SMALL LETTERS.

Back