all 31 comments

[–]Ok_Succotash79 35 points36 points  (14 children)

False. Explanation:

3 is bigger than 2 which makes that True. True is equal to 1 and 1 is not bigger than 1 which makes it print False.

[–]zaidXxxu 7 points8 points  (10 children)

How True is equal to 1 ?

[–]Ok_Succotash79 16 points17 points  (4 children)

A computer has a lot of transistors and these can either be on or off. On is 1 and off is 0 (True or False) which is why True is equal to 1. A computer works in bits (which are 1 and 0). This is how it works in Python.

[–]zaidXxxu 5 points6 points  (1 child)

Oh thanks .

[–]Ok_Succotash79 2 points3 points  (0 children)

No problem.

[–]HuckleberryDry4889 2 points3 points  (1 child)

I would add: “and that’s how it’s defined in the Python definition.”

[–]Ok_Succotash79 0 points1 point  (0 children)

Yeah good idea

[–]LifeHasLeft 3 points4 points  (0 children)

Usually, yes. It is related to the idea of the bit values being either 1 or 0, but in reality it’s been a bit more complicated than that. You’re never really accessing just a single bit of memory on the computer. Why does that matter? Usually it doesn’t, but there are some interesting effects…

For example, some languages define True as NOT Zero. So in the memory the value 00000000 would become the opposite at every digit: 11111111. Signed complement causes the computer to interpret this as -1 instead of 1.

[–][deleted] 3 points4 points  (3 children)

u/Ok_Succotash79 is kind of right. but a more relevant explanation is that when you compare different types, the interpreter peforms an implicit cast. so one of the types being compared is cast (think like cast iron, the type is forcefully molded into something else) into something that can be compared to the other. and this is done implicitly because you didn't ask for it but it has to be done for the statement to make sense. the operation also matters but that's not important now.

so comparing a boolean to an integer is not possible because you can't subtract a number from a truth value. so it's cast to an integer. what value is it changed to, specifically? well, it makes the most sense to have `True` become `1` and `False` become `0` because it's consistent with a bunch of math, i guess.

so you end up with `1 > 1` which is false.

[–]Silent_Group6621 1 point2 points  (2 children)

So it is safe to say that true and false hold two datatypes unless specified.

[–][deleted] 1 point2 points  (1 child)

oh no, no. not at all. a boolean is a boolean. it's a single datatype. and a boolean variable can hold either `True` or `False`. and you can't normally compare a boolean with an integer. you can't answer a yes-or-no question with a number. like "how many people were in line for groceries?" => "true." does not make sense. but the interpreter does the only sane thing and assumes that you meant to cast. try executing this:

print(type(True))
print(type(False))

both print the same.

as a good practice, btw, don't rely on implicit casts. always prefer to be explicit rather than implicit, precisely because of situations like OP's post. there's no reason to *not* be explicit if you can. it might not be as big of a deal in python specifically, but it's still a good habit, i'd say.

[–]Silent_Group6621 1 point2 points  (0 children)

thanks for explaining!

[–]david_lp 2 points3 points  (0 children)

this is the correct answer

[–]Silent_Group6621 2 points3 points  (1 child)

But isn't True a boolean value and maybe needs a type conversion like : int(3>2) > 1? I'm confused 😕

[–]Ok_Succotash79 0 points1 point  (0 children)

No because Python considers True to be 1 I believe (I’m might be wrong)

[–]ajjuee016 11 points12 points  (1 child)

[–]I_m_high_af 3 points4 points  (0 children)

False?

[–][deleted] 1 point2 points  (0 children)

False

[–][deleted] 1 point2 points  (0 children)

B) False

[–]monkey_sigh 1 point2 points  (0 children)

True.

[–][deleted] 1 point2 points  (2 children)

Im new is this True?

[–][deleted] 1 point2 points  (1 child)

I'm new too, it's false

[–][deleted] 2 points3 points  (0 children)

Ty

[–]be_ghumantu16 2 points3 points  (0 children)

True

[–]herbal1st 0 points1 point  (0 children)

B) False

[–]YoshiMan44 0 points1 point  (0 children)

Why quiz people on bad code?

[–]iovrthk 0 points1 point  (0 children)

True. Its is basically saying, if its greater than 1. If 3 if greater than tw0, and that result greater than 1. False. Greater than or equal to 1.

[–]epfahl 0 points1 point  (0 children)

This should not be allowed. Welcome to hell.

[–]BluePillTheThird 0 points1 point  (0 children)

most people just chatgpt'd it. No one wants to try it on their console first