I am embarrassed ... it's stupid, but I don't understand the left and right part of this equation... Could you advise me the educational site where I could learn and understand its sense? Wish it were as simple and clear as CodeAcademy with its Python... Good bye so far and best wishes
If you do not understand it, throw it into the interpreture one part at a time.
-(-(-(-2))) # OUTPUT: 2
4 >= 16**0.5 # Basically what is the square root
So all together w/o any fancy junk
2 == -2 and True
As you can see quickly now that there is no way that 2 == -2 and 4...
In math, the
- sign changes the sign of the value coming after it:
-(-5) = -1 * -5 = 5
You can do this as many times as you like:
-(-(-(-(-5)))) = -(-(-(5))) = -(-(-5)) = -(5) = -5
And python respects this aspect of math. And it does exactly what I did there with the -5, it evaluates the expression as many times as possible until its impossible to reduce. Then goes on to the rest of the expression. So when it sees the whole
-(-(-(-2))) == -2 and 4 >= 16**0.5 it will first take the
-(-(-(-2))), and before continuing to the rest of the stuff will reduce this to something readable.
-(-(-(2))) = -(-(-2)) = -(2) = -2
then continue with the rest:
-2 == -2
True. As it finds the
and it has to evaluate the whole right-hand stuff before actually computing the
4 >= 16**0.5, as you know evaluates to
True, and finally python will evaluate
True and True which returns
Yea, that is not how that works...
It's like this
-(-(-(-2))) == -1 * ( -1 * (-1 * ( -2))) # OUTPUT: True
Also a negative is like flipping a switch in regards to it's positive or negative nature. It never moves the number's absolute value but it does flip it's
And as I stated previously, if you do not understand something
Also i forgot about the comparative statement at the end thanks for reminding me I fixed ma previous post!
I can't understand this math either, and I just don't know how to continue with the lessons. Do I have to stop here and find another Python class at another site?
I don't have time to waste on just one line, the math of which I could not understand. So I cheated and copied a solution and moved on. Nice... I breezed through several more assignments and I'll stay with these lessons.
No help needed.
-2 == -2 True
-(-2) == -2 ,False, porque -(-2) = 2
-(-(-2)) == -2 , True, -(-(-2)) = -2
-(-(-(-2))) == -2 , False, -(-(-(-2))) = 2
4 >= 16**0.5 ,True, porque 16**0.5 é 4
bool_one = False and False
bool_two = True and False
bool_three = True and False
bool_four = True and True
bool_five = True and True
i feel so stupid looking at the maths in this seems its suppossed to be easy but can some one and try and explain this -(-(-(-2))) what are all of the brackets doing?
I don't understand either. I calculated is 2, how come -2 ?
-(-(-(-2))) == -1 * ( -1 * (-1 * ( -2)))
= -1* (-1* (2)
That's what I calculated
- - = +
- + = -
- + = +
- = -
It’s Simple if the no. of negative signs are odd then the result will be negative and if the no. of negative signs are even then the result will be positive.
example : -(-(-2)) = -2 and -(-2) = 2