Python True Keyword

Example

Print the result of the comparison "8 is greater than 7":

print(8 > 7)

Run Instance

Definition and Usage

The True keyword is a boolean value, which is the result of a comparison operation.

The True keyword is the same as 1 (False is the same as 0).

More Examples

Example

Other comparisons that return True:

print(5 < 6)
print(2 in [1,2,3])
print(5 is 5)
print(5 == 5)
print(5 == 5 or 6 == 7)
print(5 == 5 and 7 == 7)
print("hello" is not "goodbye")
print(not(5 == 7))
print(4 not in [1,2,3])

Run Instance

Related Pages

False Keywords.

Please visit our Python Operator Tutorial Learn more about comparisons in Chinese.