What am I supposed to assign to these variables?

Question

What am I supposed to assign to these variables?

Answer

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

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?

1 Like

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?

12 Likes

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

1 Like

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

3 Likes

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.

3 Likes

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

1.

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
1 Like

So I just tried it like this and this works.

Spoiler

#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
#1
2 <= -1
bool_three = 12 <= -1
print bool_three
#40 * 4 >= -4
bool_four = 40 * 4 >= -4
print bool_four
#100 != 10
2
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.

1 Like

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?

32 Likes

Yeah, same question here!

1 Like
  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.

Same question here too! I am basically just pressing run and then move to the next topic!

4 Likes

It looks like a bug. The Boolean answers should not all be filled in before you start the exercise.

3 Likes

All of the answers are pre-filled on these, but this exercise (and the previous, which had the same issue) seem strange.
Is the point you’re making that we (the programmer) need to think ahead about what different boolean values might be in our sequence, so that we can create efficient if/then/else?

Having the human do the math on these seems dumb when the description says the point is of booleans is to make the computer do the eval.

Answers are still automatically filled. We do nothing but hit run to pass.

yea it was like auto populated. but will I remember that later or not is the bigger question? I hit run and got the green light. moving on…

Same happened to me, quite confused

Hello @mtf Can you please help here?

This is an FAQ topic, so, no, I cannot help. We can try to sort it out, though.

1 Like

When i loaded this lesson all the variables were already assigned correctly, not just the one that has the comment “we did this one for you”. There was nothing for me to do other than double check that they were correct.