Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Python Logical Operators | ¿Verdadero o Falso?
Tipos de Datos en Python
course content

Contenido del Curso

Tipos de Datos en Python

Tipos de Datos en Python

1. Familiarizándonos con los Números en Python
2. ¿Verdadero o Falso?
3. Strings
4. Reuniendo Todos los Temas

book
Python Logical Operators

In real life, almost everyone expresses their thoughts using phrases like "Yes or No", "Definitely Not", "Yes, yes and yes!". Python language permits you to do almost the same, but it uses more formal phrases based on the statements and, or, and not. X and Y can be any logical statement (True or False):

Let's look at the code below to understand the logic of each operator:

12345678910111213
# Example of `and` operator x = True y = False result = x and y print('Result of x and y:', result) # Output: False # Example of `or` operator result = x or y print('Result of x or y:', result) # Output: True # Example of `not` operator result = not x print('Result of not x:', result) # Output: False
copy
Tarea

Swipe to start coding

Imagine you're an accountant checking the status of a financial report. Replace ___ with True or False to match the following conditions:

  • The variable report_is_valid should be True only if the report was submitted on time and signed by the manager.
  • The variable report_is_rejected should be False if the report was not submitted or not reviewed by the accountant.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
toggle bottom row

book
Python Logical Operators

In real life, almost everyone expresses their thoughts using phrases like "Yes or No", "Definitely Not", "Yes, yes and yes!". Python language permits you to do almost the same, but it uses more formal phrases based on the statements and, or, and not. X and Y can be any logical statement (True or False):

Let's look at the code below to understand the logic of each operator:

12345678910111213
# Example of `and` operator x = True y = False result = x and y print('Result of x and y:', result) # Output: False # Example of `or` operator result = x or y print('Result of x or y:', result) # Output: True # Example of `not` operator result = not x print('Result of not x:', result) # Output: False
copy
Tarea

Swipe to start coding

Imagine you're an accountant checking the status of a financial report. Replace ___ with True or False to match the following conditions:

  • The variable report_is_valid should be True only if the report was submitted on time and signed by the manager.
  • The variable report_is_rejected should be False if the report was not submitted or not reviewed by the accountant.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Lamentamos que algo salió mal. ¿Qué pasó?
some-alt