De Morgan's Law Formula Demorgan's Law is used both in set theory as well as in boolean algebra. These laws are critical in understanding mathematical arguments. Using these laws a relationship can be established between union and intersection via complementation.
Summary. De Morgan's Laws can help simplify your code to make it more readable. You can change a sequence of negated ands to something that reads as “at least one of these is required” and a sequence of negated ors to something that reads as “all of these are required.”
The Demorgan's theorem defines the uniformity between the gate with the same inverted input and output. It is used for implementing the basic gate operation likes NAND gate and NOR gate. The Demorgan's theorem mostly used in digital programming and for making digital circuit diagrams.
I use pycharm and a few times when using if
statements I have seen the suggestion to change the statement using De Morgan laws, such as with the following if
statement:
if new_odds > 10 and new_odds <= 30:
if not (not (new_odds > 10) or not (new_odds <= 20)):
For me it makes it less readable, so is there any advantage to using De Morgan's laws or is it strictly a personal choice?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With