Google News
logo
Python Program to The or keyword
In the following example of Python program that demonstrates how to use the `or` keyword :
Program :
# Using the or keyword
x = -1
y = 10

if x > 0 or y > 0:
    print("At least one of x and y is positive.")
else:
    print("Neither x nor y is positive.")
Output :
At least one of x and y is positive.
In this program, we use the `or` keyword to check if either `x` or `y` is positive. If at least one of the variables is greater than `0`, the program will execute the code in the `if` block, which prints the message "At least one of x and y is positive."

If neither variable is greater than `0`, the program will execute the code in the `else` block, which prints the message "Neither x nor y is positive."

You can use the `or` keyword to check if at least one of multiple conditions is true. This allows you to create more complex logical expressions.