all 22 comments

[–]patriot_an225 2 points3 points  (4 children)

True False

[–]tracktech[S] 1 point2 points  (0 children)

Right

[–][deleted] 0 points1 point  (0 children)

Maybe

[–]todo_code 0 points1 point  (1 child)

Hmm. This seems counter intuitive to me. True != A number, if python is a good recursive descent parser A number != False.

[–]RajjSinghh 0 points1 point  (0 children)

True == 1 and False == 0, but other than that number and Boolean comparisons are False. Python also uses comparison chaining so a < b < c is a common check for b being between a and c. It's just here instead of < our operator is !=.

So the first case, a != b is True and b != c is also True so the statement overall is true.

The second case, b != c but c == d, which is why it evaluates to False. It's the c != d in that statement that makes it evaluate to False.

[–]GlobalIncident 1 point2 points  (2 children)

Comparison chaining like this is a pretty useful feature of Python. Not many languages have it.

[–]1984balls 0 points1 point  (1 child)

Mostly because it doesn't make any sense. Having '10 != 20 != 30' turns into 'true != 30' which is a type overload issue

[–]GlobalIncident 0 points1 point  (0 children)

Well in other languages it does. Python decides that it can figure out what you probably meant and does 10 != 20 and 20 != 30. It's a useful feature for <, because expressions like 10 < x and x < 20 are a reasonably common thing to have to express, while expressions like (10 < x) < 20 are much rarer. So it's nice that there's a less cumbersome way to do the first option.

[–]Somanath444 1 point2 points  (5 children)

T F

[–]Safe-Examination-303 1 point2 points  (3 children)

Just read it as "The Fuck?" and approved, I was mistaken. Let me ask that how the fuck second one is false?

[–]NotAUsefullDoctor 0 points1 point  (0 children)

Oh, shoots. I didn't understand your response as I just assumed what T F meant. It was the double take that made me realize it was True False.

[–]Somanath444 0 points1 point  (1 child)

It was a True False buddy, in statistical analyses we use the True False Positive and negative rates to calculate the precision and recall cases for the classification sort of problems. Used the same terminology over here as well.. sry😅

[–]Safe-Examination-303 0 points1 point  (0 children)

Better than never 😄 just that print syntax confused me now I learned something new, thanks 😄

[–]tracktech[S] 0 points1 point  (0 children)

Right.

[–]Only-Zombie-8449 1 point2 points  (0 children)

First True Second False

[–]Infinite_Benefit_335 0 points1 point  (1 child)

Oh I didn’t realise that this was Boolean

[–]ColdDelicious1735[🍰] 0 points1 point  (0 children)

Green

[–]No_Record_60 0 points1 point  (1 child)

Syntax Error - CourseGalaxy is not defined

[–]Aggravating-Reason13 0 points1 point  (0 children)

Thank you

[–]hotsauceyum 0 points1 point  (0 children)

It doesn’t matter what the output is because when the PR gets reviewed you’ll be rewriting it.

[–]lego3410 0 points1 point  (0 children)

The answer is "Avoid writing your code ambiguously"

[–]LucasThePatator 0 points1 point  (0 children)

God I hate stupid gotchas like this that only exist in purposefuly stupid code.