Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Threshold Checker | Variable Scope
Intermediate Python Techniques
course content

Contenido del Curso

Intermediate Python Techniques

Intermediate Python Techniques

1. Packing and Unpacking
2. Arguments in Function
3. Function as an Argument
4. Variable Scope
5. Decorators

bookChallenge: Threshold Checker

Tarea
test

Swipe to show code editor

Develop a closure that maintains a state and can be used to perform operations based on that state.

Let's create a closure that checks if a given value exceeds a specified minimum.

  1. Start by defining the outer function, which we'll name threshold_checker;
  2. This function should accept a parameter named threshold;
  3. Next, declare an inner function called check within threshold_checker. This inner function should take one parameter, value;
  4. Inside the check function, return True if the value is greater than the threshold, and False otherwise. Use the < operator for this comparison;
  5. Finally, ensure that the outer function, threshold_checker, returns the inner function check;
  6. Assign the threshold_checker function to a variable named greater_than_10, passing 10 as the threshold value;
  7. Run Code and Submit Task.

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 4. Capítulo 7
toggle bottom row

bookChallenge: Threshold Checker

Tarea
test

Swipe to show code editor

Develop a closure that maintains a state and can be used to perform operations based on that state.

Let's create a closure that checks if a given value exceeds a specified minimum.

  1. Start by defining the outer function, which we'll name threshold_checker;
  2. This function should accept a parameter named threshold;
  3. Next, declare an inner function called check within threshold_checker. This inner function should take one parameter, value;
  4. Inside the check function, return True if the value is greater than the threshold, and False otherwise. Use the < operator for this comparison;
  5. Finally, ensure that the outer function, threshold_checker, returns the inner function check;
  6. Assign the threshold_checker function to a variable named greater_than_10, passing 10 as the threshold value;
  7. Run Code and Submit Task.

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 4. Capítulo 7
toggle bottom row

bookChallenge: Threshold Checker

Tarea
test

Swipe to show code editor

Develop a closure that maintains a state and can be used to perform operations based on that state.

Let's create a closure that checks if a given value exceeds a specified minimum.

  1. Start by defining the outer function, which we'll name threshold_checker;
  2. This function should accept a parameter named threshold;
  3. Next, declare an inner function called check within threshold_checker. This inner function should take one parameter, value;
  4. Inside the check function, return True if the value is greater than the threshold, and False otherwise. Use the < operator for this comparison;
  5. Finally, ensure that the outer function, threshold_checker, returns the inner function check;
  6. Assign the threshold_checker function to a variable named greater_than_10, passing 10 as the threshold value;
  7. Run Code and Submit Task.

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!

Tarea
test

Swipe to show code editor

Develop a closure that maintains a state and can be used to perform operations based on that state.

Let's create a closure that checks if a given value exceeds a specified minimum.

  1. Start by defining the outer function, which we'll name threshold_checker;
  2. This function should accept a parameter named threshold;
  3. Next, declare an inner function called check within threshold_checker. This inner function should take one parameter, value;
  4. Inside the check function, return True if the value is greater than the threshold, and False otherwise. Use the < operator for this comparison;
  5. Finally, ensure that the outer function, threshold_checker, returns the inner function check;
  6. Assign the threshold_checker function to a variable named greater_than_10, passing 10 as the threshold value;
  7. Run Code and Submit Task.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 4. Capítulo 7
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt