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

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

If at least one of the variables is not greater than `0`, the program will execute the code in the `else` block, which prints the message "At least one of x and y is not positive."

You can use the `and` keyword to check if multiple conditions are true at the same time. This allows you to create more complex logical expressions.