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]
3 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]3 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
When calling a function with arguments that should be modified, the __________ of those arguments are passed.
ad-work [718]

Answer:

Addresses.

Explanation:

An argument can be defined as a value that can be passed to a function.

Simply stated, an argument is a value that must be passed into a function, subroutine or procedure when it is called. This value can be passed to a function either by reference or by value.

This ultimately implies that, an argument which is also a parameter variable stores information which is passed from the location of the method call directly to the method that is called by the program.

Basically, parameters can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function.

When calling a function with arguments that should be modified, the addresses of those arguments are passed. This is simply because the argument is an address or pointer in itself and as such the function parameter being called must be a pointer.

In object-oriented programming (OOP) language, an object class represents the superclass of every other classes when using a programming language such as Java. The superclass is more or less like a general class in an inheritance hierarchy. Thus, a subclass can inherit the variables or methods of the superclass.

Hence, all instance variables that have been used or declared in any superclass would be present in its subclass object.

6 0
2 years ago
People who work the total hours for which they get paid have
Troyanec [42]
Perfect attendance and a salary
7 0
3 years ago
Read 2 more answers
Justine was interested in learning how to play the piano. She has successfully passed every level of music book and is planning
mamaluj [8]
C because she is not a mentor yet as she hasn’t taught anyone else but she has passed every level so the best would be c
5 0
2 years ago
In an interview, an appropriate response to "What is an example of one of your
Vilka [71]

Answer:

"I tend to struggle with __________, because _______________.

Explanation:

For exanple:

"I tend to struggle with my anger, because I grew up in a harsh enviroment."

or

"A weakness of mine would be my self image. I was often bullied as a kid."

3 0
3 years ago
Read 2 more answers
How has the Internet changed the design industry?
Alexandra [31]
<span>Loads of ‘easy to use’ programmes and ‘How To’ guides make it simple for anyone to put a brochure/newsletter/marketing piece together – how difficult can it be with so much help available? Technology has not only changed the way designs are accomplished, it’s changed the perception of ‘design’ from a hard earned skill to something you can learn in an afternoon off.

via </span>https://dmjcomputerservices.com/blog/technology-changed-design-industry/

4 0
3 years ago
Other questions:
  • Network signaling is a function of which layer of the osi model
    10·1 answer
  • Help PLEASE (in attachment)
    8·1 answer
  • Which software can managers use to discuss financial performance with the help of slides and charts?
    7·2 answers
  • Write a C program to implement a command called ​displaycontent ​that takes a (text) file name as argument and display its conte
    9·1 answer
  • How to write a function that counts the letters in a string in C?
    13·1 answer
  • When referring to hard drives, access time is measured in
    11·1 answer
  • I need help thanks please!
    8·2 answers
  • Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space
    13·1 answer
  • Write code which takes two inputs from the user, a number of sides followed by a side length, then creates a regular polygon wit
    10·2 answers
  • Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, et
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!