# FAQ: Code Challenge: Control Flow - Always False

This community-built FAQ covers the “Always False” exercise from the lesson “Code Challenge: Control Flow”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply ( ) below!

Agree with a comment or answer? Like ( ) to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Another way to solve this exercise apart:

def always_false(num):
if (num > 0 or num < 1):
return False

3 Likes

I just did

def always_false(num):
return False

lazy, succinct, or bad instructions? 5 Likes

the instructions cover this:

An if statement that is always false is called a contradiction. You will rarely want to do this while programming, but it is important to realize it is possible to do this.

Your code speaks volumes why you rarely see an always false if statement.

I did this and it worked def always_false(num):
if num == num:
return False

4 Likes

If we’re going to have a function that takes a parameter, then it follows we will at least evaluate that parameter and return the outcome.

``````return num and not num
``````

is itself a contradiction, only reinforcing the triviality of this exercise, while also demonstrating the relevance.

1 Like

I did
def always_false(num):
if num > num:
return True
elif num < num:
return True
else:
return False

Experianced people, what do you think about it?

1 Like

I did

``````def always_false(num):
return False
``````

Then I figured, well that’s a bit lazy. So then I did:

``````def always_false(num):
if num>num: return True
elif num<num: return True
else: return False
``````

Did you learn anything about logic from this experiment?

Would you conclude that with,

``````def always_false(num):
return num and not num;
``````

?

Mind,

``````>>> num = []
>>> always_false(num)
[]
>>> def always_false(num):
return not not num and (num and not num)

>>> always_false(num)
False
>>>
``````

weirdness explored…

``````>>> def always_false(num):
return not not num and num

>>> always_false(num)
False
>>> always_false([])
False
>>> always_false(())
False
>>> always_false({})
False
>>> always_false(1)
1
>>>
``````
``````> def always_false (num) :
>     if num <= num + 1  :
>         return False
``````

Will that not always be True?

Consider,

``````>>> def always_false(num):
return not not num and not num

>>> always_false(1)
False
>>>
``````

This will always be False for any number we pass in. It ANDs two opposites so will never be True.

Why is a variable used in this exercise?

# Write your always_false function here:

def always_false(num):
num = 0

if(num >= 0 and num <= 0):
return False

# Uncomment these function calls to test your always_false function:

print(always_false(0))

# should print False

print(always_false(-1))

# should print False

print(always_false(1))

# should print False

I was surprised that my solution didn’t work here, perhaps someone could shed some light on why it was failing to fail.

def always_false(num):
if (num > num) and (num < num):
return False

Why wouldn’t this work? How could a number be less than itself and greater than itself? Am I missing something obvious here?

1 Like

Yeah turns out I was missing something obvious…

I made a false statement return false which is true.

def always_false(num):
if (num > num) and (num < num):
return True
else:
return False

that worked

2 Likes

If it is dark, turn on a light or fetch a torch (flashlight) or light a (candle, lamp). Namely, do something to bring some light to the situation before one stumbles and stubs a toe.

Else, well there is no else. The lights are on or it isn’t dark. What more need one do?

If True and False are still a mystery, then be sure to keep looping through these exercises until that is no longer the case. Don’t go forward until this is completely ingrained. Seriously.

We see above the logical operator, `and`. One can only assume full comprehension of `True` and `False` is indicated when we see this. Further to that, we might assume an understanding of truth values, otherwise known as, truthy and falsy which refer to the evaluation of expressions which are `bool` class when type queried.

``````>>> def is_perfect(x):
from math import sqrt as root
return not root(x) % 1

>>> is_perfect(4)
True
>>> is_perfect(9)
True
>>> is_perfect(25)
True
>>> is_perfect(36)
True
>>> is_perfect(32)
False
>>>
``````

We needn’t get into what perfect squares are, only that the `return` statement is not an explicit boolean primitive, but an evaluation that can then be cast to a boolean. Such an expression is for all an intents, a `bool` type.

``````>>> n = -4
>>> type(-5 <= n < 5)
<class 'bool'>
>>> n = None
>>> type(-5 <= n < 5)
Traceback (most recent call last):
File "<pyshell#115>", line 1, in <module>
type(-5 <= n < 5)
TypeError: unorderable types: int() <= NoneType()
>>>
``````

One for the record. `None` has no type that it can relationally be compared to. Not even itself…

``````>>> None < None
Traceback (most recent call last):
File "<pyshell#116>", line 1, in <module>
None < None
TypeError: unorderable types: NoneType() < NoneType()
>>>
``````

Identity is okay…

``````>>> None == None
True
>>>
``````

Considering that `and` is used above, are given awareness to the two operands and what’s going on there. It’s two expressions both being evaluated separately then jointly to yield a boolean.

But if the yield is a boolean, do we need literals (primitives) in our code? Answer: No, we don’t. The expression yield is sufficient to fill that need.

``````return num > num and num < num
``````

The fact that you actually used `num` in this response is totally commendable and we are happy to see it. Don’t leave this topic until you are completely comfortable. It’s crucial.

what abouit this
def always_false(num):
if num < 0 or num > 0 or num == 0:
return False
else:
return True

it worked!

1 Like

i think the challenge is to only use greater then (`>`) and smaller then (`<`), not equal to.

Noted.

Will review immediately.

Thank you.

I tryed this:

def always_false(num):
if num == num:
return False

At a first attempt I used a “speech logic” instead and I putted num != num since in natural speech this has a different meaning. This was a very nice challenge for me to practice boolean logic Why will this code return “None” when num=0 or num=-1?

``````def always_false(num):
if not num < 0 and num > 0:
return False
``````