VisuAlg Web

Combinando Condições

As operações lógicas de Python usam and , or e not .

As operações lógicas de Python usam and, or e not.

Exemplo de códigoPython


age = 14
height = 1.60

# AND requires BOTH sides to be true
can_ride = (age >= 12) and (height >= 1.50)
print("Can ride the roller coaster? ", can_ride)
Exemplo de códigoPython
cash = True
card = True

# In XOR, if you have both, it returns False.
print("Paid with exactly one method?", cash != card)

# Inverting a truth with NOT
print("Am I out of cash?", not cash)