×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.