Something wrong with the solution[Compare... Closelier!]


#1

This is the Exercise I am stuck at
https://www.codecademy.com/en/courses/python-beginner-BxUFN/1/2?curriculum_id=4f89dab3d788890003000096

Instructions
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


 #Assign True or False as appropriate on the lines below!

if (20 - 10) > 15 :
    bool_one = True    # We did this one for you!
else :
    bool_one = False
    
if (10 + 17) == 3**16 :
# Remember that ** can be read as 'to the power of'. 3**16 is about 43 million.
    bool_two = True
else :
    bool_two = False

if 1**2 <= -1 :
    bool_three = True
else :
    bool_three = False

if 40 * 4 >= -4 :
    bool_four = True
else :
    bool_four = False
    
if 100 != 10**2 :
    bool_five = True
else :
    bool_five = False


The above solution is accepted by the compiler
What i can't understand here is how those conditions happen to be true only bool_four is true but rest of them must be opposite according to me.
Can anyone please explain why compiler accepted this answer? OR
Is there something wrong with the compiler(or the website)?


#2

That means doing a visual examination and evaluation of the expressions. It does not mean writing code to solve the questions. Just our eyes and mind.

This is the setup we are given. Our job is to write True or False as applies.

#Assign `True` or `False` as appropriate on the lines below!

# 20 + -10 * 2 > 10 % 3 % 2
bool_one = 

# (10 + 17)**2 == 3**6
bool_two = 

# 1**2**3 <= -(-(-1))
bool_three = 

# 40 / 20 * 4 >= -(4**2)
bool_four = 

# 100**0.5 != 6 + 4
bool_five =

#3

It looks like @mtf was able to answer it for you. I just want to input that right off the bat, the example and answer the practice gave never had an if: and else: on there. That should help clear any confusion.


#4

Yes i understood Thank you !


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.