Practical use of booleans


Hi i do understand how the boolean works but i don't now why but i am not able to imagine it's pactical use some examples would be amazing.



Easy use:

Suppose you have a video game you made.

In this game, you can enter "Cheat Codes" to allow certain extra features.

If they enter a correct Cheat Code, then you want to turn on ( Change to True ) a variable.


def cheats(input):
    if input == "God_Mode":
        infinite_health = True
    elif input == "sPeEdY":
        super_speed = True

If they enter a correct code, then they will get max health, or super speed to use.


thk great help i got confused what is the benefit of "not" statement can you give some examples


You could use not in many ways.

I use it the most for checking strings.


if letter not in "aeiou":
    #Do Something