De Morgan’s Law

According to De Morgan’s first law, the complement of the union of two sets A and B is equal to the intersection of the complement of the sets A and B

Examples:

“I don’t like chocolate or vanilla” = “I do not like chocolate and I do not like vanilla”

In this example, both statements are logically the same

De Morgan's Law

De Morgans Law in Code!

Javascript Example:

%%javascript

let x = 19;
let y = 50;

// ! means not. So !true is false.

// || means OR.
if (!(x > 20 || y > 20)) {
    console.log("I am the same condition as the one below!")
    //This will not be true since x is less than 20
}

// && means AND.
if (!(x > 20) && !(y > 20)) {
    console.log("I am the same condition as the one above!")
    //This will also not be true since x is less than 20
}

x = 50
y = 100

if (!(x < 20 || y < 20)) {
    console.log("I will be true since both is also greater than 20 now!")
    //This WILL be true since both variables are greater than 20
}

// && means AND.
if (!(x < 20) && !(y < 20)) {
    console.log("I am the same condition as the one above!")
    //This WILL be true since both variables are greater than 20
}


// In all, not(X OR Y) is the same as (not(x) AND not(Y))
<IPython.core.display.Javascript object>

Python Example:

x = 19
y = 50

if not (x > 20 or y > 20):
    print("Im not gonna be true since X is less than 20")
    # This will not be true since x is less than 20

if not (x > 20) and not (y > 20):
    print("I am the same condition as the one above!")
    # This will also not be true since x is less than 20

x = 50
y = 100

if not (x < 20 or y < 20):
    print("I will be true since both x and y are greater than 20 now!")
    # This WILL be true since both variables are greater than 20

if not (x < 20) and not (y < 20):
    print("I will also be true since both x and y are greater than 20 now!")
    # This WILL be true since both variables are greater than 20

# In all, not(X OR Y) is the same as (not(X) AND not(Y))
I will be true since both x and y are greater than 20 now!
I will also be true since both x and y are greater than 20 now!