Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Priorities | True or False?
Data Types in Python
course content

Contenu du cours

Data Types in Python

Data Types in Python

1. Getting Familiar With Numbers in Python
2. True or False?
3. Strings
4. Bring All the Topics Together

book
Priorities

Hi there! It is time to train your logical skills. Good luck!🤔

Programming-wise, it is vitally important to be good at prioritizing logical statements, like and and or. In the previous section, you were working with math operations, especially with + and *. I can guess that you remember from school that * has a greater importance than +; therefore, the same applies to and and or.

Note

and is multiplication for boolean statements, and or is addition; hence, and has more prominence.

Let's examine an example and make a guess about the result! If you're worried about making an error, feel free to check the hints in this chapter and refer to the table. Keep in mind that you should perform the action inside the brackets first!

12
statement = ((True or True) and False) or True print(statement)
copy

Let's break down this statement and look at each iteration to avoid any misunderstanding:

  1. ((True or True) and False) or True;
  2. (True and False) or True;
  3. False or True;
  4. True.

Note

In each iteration, we simplify the most prioritized part of this expression and replace it with its result. For example, the expression (True or True) becomes True.

Tâche

Swipe to start coding

Replace the ___ parts of code with True or False to make all variables equal True.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
toggle bottom row

book
Priorities

Hi there! It is time to train your logical skills. Good luck!🤔

Programming-wise, it is vitally important to be good at prioritizing logical statements, like and and or. In the previous section, you were working with math operations, especially with + and *. I can guess that you remember from school that * has a greater importance than +; therefore, the same applies to and and or.

Note

and is multiplication for boolean statements, and or is addition; hence, and has more prominence.

Let's examine an example and make a guess about the result! If you're worried about making an error, feel free to check the hints in this chapter and refer to the table. Keep in mind that you should perform the action inside the brackets first!

12
statement = ((True or True) and False) or True print(statement)
copy

Let's break down this statement and look at each iteration to avoid any misunderstanding:

  1. ((True or True) and False) or True;
  2. (True and False) or True;
  3. False or True;
  4. True.

Note

In each iteration, we simplify the most prioritized part of this expression and replace it with its result. For example, the expression (True or True) becomes True.

Tâche

Swipe to start coding

Replace the ___ parts of code with True or False to make all variables equal True.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
We're sorry to hear that something went wrong. What happened?
some-alt