Usando o operador "and"

Published by OwenPauptit in

Python tem um operador lógico chamado and. O operador and recebe dois valores booleanos e retorna True se ambos os valores forem True.

Considere a and b:

  • Verifica-se se a é True ou False.
  • Se a for False, False será retornado.
  • Verifica-se se b é True ou False.
  • Se b for False, False será retornado.
  • Caso contrário, True será retornado (porque a e b são True).

O operador and só retornará True para True and True.

Crie uma função usando o operador and.

Exemplos

And(True, False) ➞ False

And(True, True) ➞ True

And(False, True) ➞ False

And(False, False) ➞ False

Notas

N/A