python logical and operator code example

Example 1: operators in python

# Python Operators
Operator	Name			Example
+			Addition		x + y	
-			Subtraction		x - y	
*			Multiplication	x * y	
/			Division		x / y	
%			Modulus			x % y	
**			Exponentiation	x ** y	
//			Floor division	x // y

Example 2: ** in python

#** is the exponent symbol in Python, so:
print(2 ** 3)
#output: 8

Example 3: logical operators python

Python uses and and or conditionals.

i.e.

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

Example 4: 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