Fill in the Comparator (Solution)

00:00 So the first task we’re at 3 __ 4. Now we have to replace this with a Boolean comparator so that it returns True. I can see that 3 is smaller than 4, so this should return True. There you go.

00:19 Note that if you used a different Boolean comparator, then that can be okay as well, as long as the expression evaluates to True.

00:27 Then let’s try the next one. We have 10 and then 5. And then again, we have to fill something in there to make this True.

00:35 So 10 is bigger than 5, so that should be True. You could also do something like 10 >= 5. That should also be true.

00:47 Or 10 != 5. So there’s a lot of different solutions to all of these exercises, all right? You just want to put in some Boolean comparator that makes this expression be True. The next one we have is that "jack"

01:06 and "jill" get compared, and we want to know how we can make this expression True. So I would say for the fun of it, let’s avoid using the != (not equals) comparator, which would also return True.

01:21 But instead, let’s practice using the < (smaller than) or > (bigger than) comparators with strings. So, the first letter of these two strings is the same.

01:30 Then it moves on, comparing the next letter. And here, "a" is smaller than "i", so if I put in here <, "jack" < "jill", then this should return True.

01:41 If you’re surprised why this string comparison works the way you’ve just seen, then revisit the Python Basics course that these review exercises are based on.

01:50 And then we have one more that is 42 and the string "42". We had something similar in the previous exercise. So these two are not equal.

02:01 So we can say 42 as an integer is not equal to the string "42". That should be True as well. Okay, so

02:13 we solved this with the following Boolean comparators: we used 3 < 4 10 > 5, the string "jack" is smaller than the string "jill". And again, this is because of the second letter in here.

02:25 The first one is the same, but the second one in "jack" has a lower index than the one in the right string. And then we also compared 42, the integer, to the string "42" and said that these two are not equal to each other. Great, so you’re getting warmed up a little. Let’s ramp up the difficulty a little bit.

Become a Member to join the conversation.