VOOZH about

URL: https://www.geeksforgeeks.org/python/python-true-keyword/

⇱ Python True Keyword - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python True Keyword

Last Updated : 23 Jul, 2025

True is a built-in Boolean value that represents truth or logical true value. It is one of the two Boolean constants (True and False) and is often used in conditions, loops and logical operations.

Python treats True as 1 when used in arithmetic operations and as a truthy value in conditional statements (if-else). Let's take an example.

The print statement will always get executed here because the condition is set to True.

Let's look at some examples that involve using True keyword.

Example 1: Using True in Conditional Statements


Output
x is greater than 5

Explanation: x>5 evaluates as True, hence print statement in if condition gets executed.

Example 2: Using True in Loops.

True keyword is often used with while loop to create infinite loop.


Output
0
1
2
3
4

Example 3: Using True as 1 in Arithmetic Operations.


Output
6
3

Explanation: Python considers True equal to 1 in arithmetc calculations, therefore True + 5 and True + 3 equals 6 and 4 respectively.

Comment
Article Tags:
Article Tags: