Python True Keyword

The "True" keyword in Python is basically a Boolean value. There are two boolean values: True and False. The "True" is basically a result of:

For example:

a = 10
b = 20
c = 10

print(a==c)
print(a<b)

The output is:

True
True

Python True keyword example

True is the result of a boolean operation. That is, if the expression(s) of a boolean operation evaluate to be True, then the condition evaluates to be True. Here is an example that demonstrates it:

print("Enter any Two Values: ", end="")
a = input()
b = input()

x = a==b
if x:
    print("\nBoth values are equal")
else:
    print("\nBoth values are not equal")

print("\nThe value of x =", x)

The snapshot given below shows the sample run of the above program, with user input "codescracker" as the first and second values:

python true keyword

Advantages of the True keyword in Python

Disadvantages of the True keyword in Python

The "True" keyword should be used with caution and intelligence to avoid errors and ambiguity in programming. The "True" keyword enables more intricate logical operations and algorithm design.

Python Online Test


« Previous Tutorial Next Tutorial »


Liked this post? Share it!