What am I supposed to assign to these variables?



What am I supposed to assign to these variables?


The variables bool_one through bool_five are meant to be assigned the value True or False depending on whether or not the expressionabove it is true or false.
When trying to determine the truth value of a expression, it can be helpful to break down each side of an operator before trying to solve the entire expression. Let’s look at the example below:

# Consider the expression: (35 + 20) <= ((100 - 50) +5)
# The left half results in 55
# The right half has two parts that result in (50) + 5, or 55
bool_googol = True  # 55 is indeed less than or equal to 55

FAQ: Learn Python - Conditionals & Control Flow - Compare... Closelier!

Do you have to put a comment before the variable for the True or False answer to be associated with it?
How do I know what i put will take the true or false statement?
-mostly talking about this part of the code - # (20 - 10) > 15 is this how you make the true and false statement?


Am I supposed to be the one who decide whether each variable is true or false depending on the expression you gave for each variable or am I supposed to write something that makes the program know that the truth value of each variable depended on the expressions you gave for each variable?


What difference does the double * make (**) compared to a single *? Are we to multiply the sum twice?


the ** represents exponential multiplication like raised to the 10th, if i’m not mistaken


It’s been given in the script.py as "# Remember that ** can be read as 'to the power ". For example 3**4 means 3 to the power of 4 which is (3 x 3 x 3 x 3) equal to 81.


what is the answer for this, I cant seem to see the answer?


Let’s run through the comparators again with more complex expressions. Set each variable to True or False depending on what you think the result will be.

  • Set bool_one to the result of (20 - 10) > 15
  • Set bool_two to the result of (10 + 17) == 3**16
  • Set bool_three to the result of 1**2 <= -1
  • Set bool_four to the result of 40 * 4 >= -4
  • Set bool_five to the result of 100 != 10**2


So I just tried it like this and this works.


#Assign True or False as appropriate on the lines below!
#(20 - 10) > 15
bool_one = (20 - 10) > 15 # We did this one for you!
print bool_one
#(10 + 17) == 316
#Remember that ** can be read as ‘to the power of’. 3
16 is about 43 million.
bool_two = (10 + 17) == 316
print bool_two
2 <= -1
bool_three = 12 <= -1
print bool_three
#40 * 4 >= -4
bool_four = 40 * 4 >= -4
print bool_four
#100 != 10
bool_five = 100 != 10**2
print bool_five

My question is if this is the wrong way to do it? The outcome stays the same though.


Am I being stupid or has this exercise been filled in for me? All the answers to this were already recorded as being True or False and all were correct. Confused?


Yeah, same question here!

  1. You can put the comment ‘#’ wherever you want. It can come before, at the end of the statement line, or afterwards. It’s a matter of coding style but being that the comment is supposed to tell us something about what you are about to ‘state’ then it makes sense that we put it before or above the statement line.
  2. The CodeAcademy process that evaluates your program is simply looking for:
    bool_five = False
    It is assuming that this variable is being set according to a ‘comment’ above it (100 != 100**2) and therefore in your comment you could put # Today is the end of the world and then set bool_five = False and it wouldn’t know what exactly you’re declaring the variable to be.
  3. Your comment line ‘#’ does nothing to make the statement True or False.

Hopefully that answers all your questions.