Home » Python

True keyword with example in Python

Python True keyword: Here, we are going to learn about the True keyword with example.
Submitted by IncludeHelp, on April 15, 2019

Python True keyword

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 of True keyword

    True

Example:

    Input:
    x = True

    # print
    print(x)

    Output:
    True

Python examples of True keyword

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.