Home »
Python
Python True Keyword
By IncludeHelp Last updated : December 07, 2024
Description and Usage
True is a keyword (case-sensitive) in python, it is a Boolean value (a value of class type bool). True is the result of a comparison operation.
Syntax
Syntax of True keyword:
True
Sample Input/Output
Input:
x = True
# print
print(x)
Output:
True
Example 1
Assign True to a variable, print the value and print type of True.
# python program to demonstrate example of
# True keyword
# assigning True to a variable
x = True
# printing the value
print("x: ", x)
# printing type of True
print("Type of True:", type(True))
Output
x: True
Type of True: <class 'bool'>
Example 2
Printing the result of some of the comparison operations.
# python program to demonstrate example of
# True keyword
a = 10
b = 20
print(a>=10 and b>=20)
print(a==10 and b==20)
print(a!=20 and b!=10)
print(a>5 and b>10)
Output
True
True
True
True