Booleans and Operators

# Set Booleans - these are not strings 
valid = True
not_valid = False 

# Check Booleans 
print(valid == True)
print(not_valid == False)

# Using operators for comparisons 
print((10 < 9))
print((10 == 9))
print((10 != 10))
print((10 >= 10))
print((10 <= 10))
print((10 > 9))

# Bitwise & and | comparisons 
x = 13 
y = 5 
print(bin(x & y)[2:].rjust(4,"0"))
print(bin(x | y)[2:].rjust(4,"0"))

# Bit shift 
x = 13 
print(bin(x >> 1)[2:].rjust(4,"0"))

Last updated