What am I supposed to assign to these variables?


#1

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

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

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?


#3

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?


#4

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


#5

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


#7

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.


#8

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

#9

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.