VisuAlg Web

Comparando Valores

Comparações em Python usam == , != , < , > , <= e >= , retornando True ou False .

Comparações em Python usam ==, !=, <, >, <= e >=, retornando True ou False.

Exemplo de códigoPython


age = 15
print("Is older than 18? ", age > 18)  # False
print("Is 15 or younger? ", age <= 15)  # True
Exemplo de códigoPython


typed_password = 1234
name = "Anna"

print("Is the password correct? ", typed_password == 1234)
print("Is the logged-in user not John? ", name != "John")