FAQ: Learn Python - Conditionals & Control Flow - Or

This community-built FAQ covers the “Or” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise Or:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

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

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

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

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

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

It seems that the third boolean should be “True”. However the excercise tells me that I need to check my value for the third boolean.

The expression being evaluated is:

100 ** 0.5 >= 50 or False

I read the left side of the expression as… 100 to the power of 0.5 is greater than or equal to 50. This would be true.

This would mean that the left side of the “or” is True, while the right side is False. This would equal a Boolean “True” value.

Is this an error in the excercise?

example

100 ** 0.5 isn’t 50. How do you get to 50? 100 ^ 0.5 is the same as square root of 100, which is 10.

1 Like

when I am instructed to set bool_two to the result of true or false and bool_four to the result of true or true, is the program implying that I write a equations utilizing proper boolean operators, or that I simply demonstrate my understanding if how “or” works by setting each bool to true?

you need to set each variable to a boolean value, to see you understand how to or operator works

Thank you for your help!

In other words, do it in your head, without using the computer.

Hi guys, I’m trying to understand one thing. In conditionals and control, in the “or” exercises, you have to determine if the result is False or True.

This one : 2 ** 3 == 108 % 100 or ‘Cleese’ == ‘King Arthur’
is supposed to be True…why? I don’t understand. Both sides are for me False and thus the result should be False…or why is one of those sides True?
Thanks in advance

OR expressions only require one operand to evaluate to True for the expression to yield as True. In the above, the second operand is not even evaluated since the first operand is True.

2 ** 3     =>  8

108 % 100  =>  8

8 == 8     => True

I think I have misunderstood the whole “remainder division”-thing, that is, how it works…care to explain how it works?

1 Like

In Python, remainder division can be performed on floats or integers, so writing,

 3.14 % 2

will result in 1.14, the remainder.

When we write with integers only,

314 % 200

the result is 114.

In all instances of modulo division, the quotient is an integer. If the divisor and or dividend are floats, the modulo will be a float.

Think of when we first learned long division with paper and pencil. We were never told that the remainder had another name (modulo) only that it was the remaining portion of the dividend that was smaller than the divisor. The modulo is always smaller than the divisor.

19 % 9  => 1

19 - 1  => 18

18 / 9  =>  2

so, 2 * 9 + 1 == 19

1 Like

Thanks a lot, I think I get it now!

1 Like

So glad you asked this! I now realise it was my misunderstanding that the modulo and not the quotient was shown rather than my lack of Monty Python knowledge gave me the wrong ansewr

I’m sorry I don’t think I understand. Do you mean we should be inputting expressions that equal to the true and false statements? I’m very confused about what bool_two is asking for in general. If I try to get bool_two to return two different bools I’m unsure how as a or bool should only give us one true or false

The expression results in either False or True, so you should manually evaluate the expression and then set the variable to this Boolean value

Am I missing something? How does me copying and pasting the values teach anything about this excercise?

You shouldn’t be copy pasting. You should manually solve the comparison, then set the variable to the right Boolean value.

1 Like

Rather than copying and pasting, you should evaluate the expression yourself and then enter the answer, either True or False into the editor. That’ll teach you how o think about and evaluate expressions.