Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Mixed Logic and Range | Common Logic and Comparison Errors
Common Python Mistakes and How to Fix Them

bookChallenge: Mixed Logic and Range

Tâche

Swipe to start coding

Fix the logic, comparison, and range errors in the function so it works as intended:

  • For each number in the numbers list, check if it is between 10 and 20, inclusive.
  • If a number is in this range, label it as "in range"; otherwise, label it as "out of range".
  • Return a list of tuples, each containing the original number and its label.

Example output for the call filter_and_label([9, 10, 15, 20, 21]) should be: [(9, 'out of range'), (10, 'in range'), (15, 'in range'), (20, 'in range'), (21, 'out of range')]

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 5
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

Awesome!

Completion rate improved to 5.26

bookChallenge: Mixed Logic and Range

Glissez pour afficher le menu

Tâche

Swipe to start coding

Fix the logic, comparison, and range errors in the function so it works as intended:

  • For each number in the numbers list, check if it is between 10 and 20, inclusive.
  • If a number is in this range, label it as "in range"; otherwise, label it as "out of range".
  • Return a list of tuples, each containing the original number and its label.

Example output for the call filter_and_label([9, 10, 15, 20, 21]) should be: [(9, 'out of range'), (10, 'in range'), (15, 'in range'), (20, 'in range'), (21, 'out of range')]

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 3. Chapitre 5
single

single

some-alt