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
What is the default left margin in word 2003 document ?
forsale [732]

Answer:

1.25 inches

Explanation:

It is 1.25 inches or 3.17 cm which is the left and right margin in the " Word 2003 document". And 1 inch or the 2.54 cm is being set as both sides left and right standard margin and 1.25 inches are also set for the top and bottom margin in the "Word 2003 document". And hence, by default, the left margin in Word 2003 document happens to be 1.25 inches.

8 0
3 years ago
Obtain the Truth tables to the following Boolean expressions, and prove the solution's in sagamath
nlexa [21]
The answer to your question is b☺️☺️
4 0
3 years ago
Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
Wewaii [24]

Answer:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int main()

{

//First we declare string variables to store file names for input and output

   string inputName;

   string outputName;

   string sentence;

// Then declare char variable to get current char

   char ch;

//The following section will prompt theuser to enter the file names and read

   cout << "Enter input file name:\n";

   cin >> inputName;

   cout << "Enter output file name:\n";

   cin >> outputName;

//ignore newline character left inside keyboard buffer

   cin.ignore();

//Next we define the input and output files to be opened

   ifstream inputFile(inputName);

   ofstream outputFile(outputName);

   if(!inputFile && !outputFile){

       cout << "Error while opening the files!\n";

       cout << "Please try again!\n";

       //end program immediately

       return 0;

   }

//Using this loop to get lines one by one, delimited by '.'

   while(getline(inputFile, sentence, '.')){

       //bool variable to store if we have already

       //printed capital first letter

       bool alreadyCapitalized = false;

       //Using of for loop on all characters of sentence

       for(int counter = 0; counter < sentence.length(); counter++){

           //if not alphabetical character,

           //so whitespace or newline, print as is

           if(!isalpha(sentence[counter]))

               outputFile << sentence[counter];

       //Condition statement for if it is alphabetical and no capitalization has been done, print it as uppercase

           if(!alreadyCapitalized && isalpha(sentence[counter])){

               outputFile << (char)toupper(sentence[counter]);

               alreadyCapitalized = true;

           }

           //otherwise print this condition as lowercase

           else if(alreadyCapitalized)

               outputFile << (char)tolower(sentence[counter]);

       }

       //Printing of the output sentence with period in the end

       outputFile << ".";

   }

   //Closing the files

   inputFile.close();

   outputFile.close();

   return 0;

}

5 0
3 years ago
What is an effective way to display calculations in a Word document
DanielleElmas [232]
On the main Ribbon, click on Insert tab, in the Symbols Group click the arrow under Equations, and then Insert new equation.
5 0
3 years ago
Read 2 more answers
Question 7 (1 point)
Vlada [557]

Answer:

technical knowledge

Explanation:

8 0
3 years ago
Other questions:
  • Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719,
    7·1 answer
  • â________________ software can sometimes be used to decrypt a drive that is utilizing whole disk encryption.
    15·1 answer
  • You accidentally moved your task bar from the bottom of the screen to the left side. You would like to
    14·2 answers
  • Write a C function check(x, y, n) that returns 1 if both x and y fall between 0 and n-1 inclusive. The function should return 0
    6·1 answer
  • Stored information about a previous visit to a web site is called information _____.
    10·1 answer
  • Note: You can use a word document to write your answers and copy-paste your answer to the area specified. a. (5 points) Convert
    12·1 answer
  • BRAINLIEST 14 points
    7·2 answers
  • In order to access the internet, it is not necessary to have an Internet Service Provider (ISP).
    6·2 answers
  • Which tab do you open to access the Comments feature?
    11·1 answer
  • Select the correct text in the passage.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!