1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SVETLANKA909090 [29]
4 years ago
8

Write a function similar to keep_ints like before, but now it takes in a number n and returns a function that has one parameter

cond. The returned function prints out numbers from 1 to n where calling cond on that number returns True.
Computers and Technology
1 answer:
lukranit [14]4 years ago
5 0

Answer:

def make_keeper(n):

   """Returns a function which takes one parameter cond and prints

   out all integers 1..i..n where calling cond(i) returns True.

   >>> def is_even(x):

       # Even numbers have remainder 0 when divided by 2.

       return x % 2 == 0

   >>> make_keeper(5)(is_even)

   2

   4

   """

   def fun(cond):

       for i in range(1,n):

           if(cond(i)):

               print(i)

   return fun

Explanation:

  • Define a function called fun that takes cond as input.
  • loop from 1 to n and display the value if it meets the requirement.
You might be interested in
Kelly completes a bachelor's degree in animation from a top school in New York. She would now like to look for a job that will p
nikdorinn [45]
I believe she would have a best chance in a media production house, animation is a form of media and would be best put to use there.
8 0
3 years ago
Read 2 more answers
Tracking a basketball's backspin with an internal sensor can...
valkas [14]
Help a player improve one part of this shooting technique
5 0
3 years ago
Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int d
xeze [42]

Answer:

void showSquare(int param){

}

Explanation:

In C++ programing language, this is how a function prototype is defined.

The function's return type (In this case Void)

The function's name (showSquare in this case)

The function's argument list (A single integer parameter in this case)

In the open and closing braces following we can define the function's before for example we may want the function to display the square of the integer parameter; then a complete program to accomplish this in C++ will go like this:

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>void showSquare(int param);</em>

<em>int main()</em>

<em>{</em>

<em>    showSquare(5);</em>

<em>    return 0;</em>

<em>}</em>

<em>void showSquare(int param){</em>

<em>int square = param*param;</em>

<em>cout<<"The Square of the number is:"<<endl;</em>

<em>cout<<square;</em>

<em>}</em>

8 0
4 years ago
The arguments supplied to the IF function, in order, are the condition for execution, a. and the range of cells to test. b. the
Oksi-84 [34.3K]

Answer:

D. the result if condition is true, and the result if condition is false.

Explanation:

The syntax for the IF function is IF(logical_test, value_if_true, [value_if_false]). Therefore, the arguments supplied to the IF function, in order, are the condition for execution, the result if the condition is true, and the result if the condition is false.

4 0
3 years ago
In the U.S. a standard mortgage requires a down payment of
Doss [256]
Atleast a minimum of 3%. Brainliest? 
6 0
4 years ago
Other questions:
  • A cyberbully is someone who invades another person’s privacy by
    13·2 answers
  • Which file type is used for animated images?
    9·1 answer
  • Membrane-bound organelles are not found in the cells of A) bacteria. B) fungi. C) plants. Eliminate D) protists.
    15·2 answers
  • What is a type of destructive program?
    8·2 answers
  • Universal Containers is creating a custom Visualforce page to allow users to edit contact records. The developer has used an ape
    6·1 answer
  • Explain how the operating system controls the software and hardware on the computer?
    5·1 answer
  • ICD-10-CM diagnosis codes are entered in Block 21 of the CMS-1500 claim. A maximum of __________ ICD-10- CM codes may be entered
    14·1 answer
  • PLEASEEEEE HELLPPP IT'S URGENT!!!
    11·1 answer
  • A proposal is also known as a
    14·2 answers
  • Give the an example of the following .<br>a.)typing software<br>​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!