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
Sonbull [250]
3 years ago
7

Write a function (funception) that takes in another function func_a and a number start and returns a function (func_b) that will

have one parameter to take in the stop value. func_b should take the following into consideration the following in order: Takes in the stop value. If the value of start is less than 0, it should exit the function. If the value of start is greater than stop, apply func_a on start and return the result. If not, apply func_a on all the numbers from start (inclusive) up to stop (exclusive) and return the product.
Computers and Technology
1 answer:
castortr0y [4]3 years ago
3 0

Answer:

The code for this question can be defined as follows:

def funception(func_a, start):#define a method funception that accept two parameter

   def func_b(stop): #define a method func_b that accept one parameter

       if start < 0:#define if block that checks start parameter value less then 0

           return #Use return keyword

       if start > stop:#define if block that checks start parameter value greater then stop parameter value

           return func_a(start)#use return keyword to call func_a method

       else:#define else block

           product = 1#define a variable product and assign a value 1

           for i in range(start, stop):#define for loop to calculate the value

               product= product * func_a(i)#multiply the method value in product variable

           return product#return prod value

   return func_b#return func_b value

def func_a(num):#define a method func_a that accept a num variable as a parameter

   return num + 1#use return keyword by increment num value by 1

Explanation:

In the above python program code, a method "funception" is defined that accepts two parameters that are "func_a and start", in which "func_a" is a method name, that accepts a "num" variable in its parameter and returns its one increment value.

  • Inside the method, another method that is "func_b" is defined that accepts a "start" variable in its parameter and uses it if block to check "start and stop" values.
  • If the start value is less then 0 it will exit the program. If the start value is less then stop value so, it will return the "func_a" value.
  • In the else part, a "product" variable is defined that multiplies the method "func_a" value and returns its value.
You might be interested in
7.3 Code Practice edhesive
sladkih [1.3K]

Answer:

def print_sum(a,b,c):

 print(a+b+c)

one = int(input("Enter the 1st number: "))

two = int(input("Enter the 2nd number: "))

three = int(input("Enter the 3rd number: "))

print_sum(one,two,three)

Explanation:

hope this helped :)

5 0
3 years ago
Read 2 more answers
Write a class called SimpleSquare that has the following properties: - public int field called num - private int field called sq
mezya [45]

Answer:

public class SimpleSquare{

   public int num;

   private int square;

   

   public SimpleSquare(int number){

       num = number;

       square = number * number;

   }

   

   public int getSquare(){

       return square;

   }    

}

Explanation:

*The code is in Java.

Create a class called SimpleSquare

Declare two fields, num and square

Create a constructor that takes an integer number as a parameter, sets the num and sets the square as number * number.

Since the square is a private field, I also added the getSquare() method which returns the value of the square.

6 0
3 years ago
The term used to describe the shape and layout of a computer component such as a motherboard or hard drive is __ factor?
Flauer [41]
FORM factor. Example are ATX, micro ATX, and many more. ATX and MATX are the most common next to servers as well
3 0
3 years ago
What task do the referential integrity settings prevent?
Cerrena [4.2K]

Answer:

D

Explanation:

5 0
3 years ago
Read 2 more answers
How to solve level 53 on rapid router?
alexgriva [62]

&lt;img src=/static/game/image/actions/go.svg alt=' + ugettext(play= button)= += '= style=width: 4%;&gt; ) def noPermissionMessage():

6 0
2 years ago
Other questions:
  • A wireless (radio) transmission of data can only travel a short distance.<br><br> True or false?
    9·1 answer
  • The most effective way to perform data entry is to keep your hands on the keyboard and press to move to the text cell in the row
    10·1 answer
  • …………………..is made upof plastic or glass fibers that transmit data at very fastspeeds.
    10·1 answer
  • When you move or size a control in the Form Designer, Visual Studio automatically adjusts the ________________ that specify the
    9·1 answer
  • Can anyone help me with getting bash ubuntu on windows setup?
    15·1 answer
  • What do you believe are the motives of a cyber criminal? Why?
    15·1 answer
  • After correctly configuring a new wireless enabled thermostat to control the temperature of the company's meeting room, Joe, a n
    6·1 answer
  • The CMOS battery located on a computer's motherboard allows for maintaining the correct time and date information stored in CMOS
    7·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • What are logic gates ?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!