6/15 bool_four is?


#1

The code won't run whether you enter True or False for the answer? What?!? It has to be one or the other.


#2

I am having the same problem


#3

Not sure I understand the problem you are experiencing..?

The instruction goes as follow:

Set bool_four equal to the result of -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

so if we print the segments:

print -(1**2) < 2**0            # will return True
print 10 % 10 <= 20 - 10 * 2    # will return True as well

# so...
bool_four = -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2
print bool_four                 # will return True since True and True will be True

#4

It doesn't say anything about printing, the bool should be True, but as the original poster says, whether you use True or False it keeps saying to check the answer! So anyone from codeacademy reading please can you help?!


#5

@pyrockstar24582:

Please paste the code you are trying to run otherwise it is very difficult to try and help you! :smile:

Here's a little trick:

Whenever you would like to paste code, since this forum supports Markdown you can use three backticks before and after your code block like so:

```
def my_func(x):
my_var = 0
if x > my_var:
sum = my_var + x
else:
print "Odelay!"
return sum
```

and it will retain proper indentation and even have nifty syntax highlighting:

def my_func(x):
    my_var = 0
    if x > my_var:
      sum = my_var + x
    else:
      print "Odelay!"
    return sum

#7

Also, you are right it is not necessary to print for the exercise to be completed, but sometimes using print statement helps us debug and understand what's going on under the hood which in turn makes the solution to our problem much more obvious and that's why I was using them.


#11

I'm experiencing the same issue. I have thrown the code into the IDE, works just well. The problem is with the site I think at this point because it is failing to read the correct answer which is True.
This is what I am dealing with:

bool_four = -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2 is True

The response I am getting is:

Oops, try again. Double check your value for bool_four!


#12

@chinyani:

Please copy and paste your entire code here so we can try and find what is wrong. It is common to have an error message points something (in this case bool_four) but having the actual problem lies somewhere else in the code or in the indentation of it.

Use the code formatting trick I have posted earlier in this thread to keep indentation verbatim since without it, proper troubleshooting is impossible for us...

Thank you! :smile:


#13

@chinyani:

Here is my code. It worked in the lab but it also worked in the exercise with the codecademy code validator.

Copy and paste your code somewhere and replace it with the following and see if it works. Report here with your results. Still do post your code here please so we can try and find what is wrong. :smile:

bool_one = False and False

bool_two = -(-(-(-2))) == -2 and 4 >= 16 * 0.5

bool_three = 19 % 4 != 300 / 10 / 10 and False

bool_four = -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

bool_five = True and True

#14

It worked right. Thanks very much for your help. My code was something like this:

bool_one = False and False

bool_two = -(-(-(-2))) == -2 and 4 >= 16 * 0.5

bool_three = 19 % 4 != 300 / 10 / 10 and False

bool_four = (1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

bool_five = True and True

My bool 4 had no NEGATIVE sign just as it is above.



#15

Great @chinyani, I'm glad I could help you find it!

Remember, for your next requests on this forum, to wrap your code with three backticks (like these ```) before and after your code. You can also use the symbol that looks like this </> in the message editor toolbar. Both will create a code block and will have your code rendered properly, this way we can start troubleshooting and helping you right away.

Good luck! :smile:


#16

The same I had. To get through that error (IMO), could be used some other expression, e.g.:


#17

I had no issue submitting the answer. What I don't understand is why bool_four is TRUE. The result of the equation should be True and False, which should return the result as False. Anyone could help explain?


#19