python logical or code example

Example 1: python or

x = 1
y = 10

if x%2 == 0 or y%2 == 0:
  print(x%2)
  
#Output#
#1

Example 2: logical operators in python

condition1 and condition2
condition1 or condition2
not condition

Example 3: and in python

#And opreator in python

a = 12
b = 56

print(a and b * 12)

Example 4: logical operators python

Python uses and and or conditionals.

i.e.

if foo == 'abc' and bar == 'bac' or zoo == '123':
  # do something

Example 5: logical operator in python

# logical and operator
# return first operands if false otherwise second operands

0 and 3
# output = 0
3 and 0 
# output = 0
3 and 5 
# output = 5