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
bearhunter [10]
3 years ago
10

"Write an iterative function iterPower(base, exp) that calculates the exponential baseexp by simply using successive multiplicat

ion. For example, iterPower(base, exp) should compute baseexp by multiplying base times itself exp times"
Computers and Technology
1 answer:
sp2606 [1]3 years ago
5 0

Answer:

I am writing the function using Python. Let me know if you want the program in some other programming language.            

def iterPower(base, exp):    

    baseexp = 1

    while exp > 0:

        baseexp = baseexp*base

        exp= exp - 1

    return baseexp

base = 3

exp = 2

print(iterPower(base, exp))

Explanation:

  • The function name is iterPower which takes two parameters base and exp. base variable here is the number which is being multiplied and this number is multiplied exponential times which is specified in exp variable.
  • baseexp is a variable that stores the result and then returns the result of successive multiplication.
  • while loop body keeps executing until the value of exp is greater than 0. So it will keep doing successive multiplication of the base, exp times until value of exp becomes 0.
  • The baseexp keeps storing the multiplication of the base and exp keeps decrements by 1 at each iteration until it becomes 0 which will break the loop and the result of successive multiplication stored in baseexp will be displayed in the output.
  • Here we gave the value of 3 to base and 2 to exp and then print(iterPower(base, exp)) statement calls the iterPower function which calculates the exponential of these given values.
  • Lets see how each iteration works:
  • 1st iteration

baseexp = 1

exp>0 True because exp=2 which is greater than 0

baseexp = baseexp*base

               = 1*3 = 3

So baseexp = 3

exp = exp - 1

      = 2 - 1 = 1    

exp = 1

  • 2nd iteration

baseexp = 3

exp>0 True because exp=1 which is greater than 0

baseexp = baseexp*base

               = 3*3 = 9

So baseexp = 9

exp = exp - 1

      = 1-1 = 0    

exp = 0

  • Here the loop will break now when it reaches third iteration because value of exp is 0 and the loop condition evaluates to false now.
  • return baseexp statement will return the value stored in baseexp which is 9
  • So the output of the above program is 9.
You might be interested in
A data mart differs from a data warehouse in that: Group of answer choices it deals with a particular component or functional ar
pickupchik [31]

Answer:

A Data Warehouse is a corporate database that integrates purified information from the various sources in the organization. This information must be homogeneous and reliable, it is stored in a way that allows its analysis from many different perspectives, and that it is in turn of the optimal response times. For this, the information is highly denormalized and modeled in a way quite different from transactional systems, mainly the star models (star scheme) and snowflake (snowflake scheme) that we will study later.

A Data Warehouse is much more than what we have commented so far. According to Bill Inmon it is characterized by being:

Theme-oriented: data is organized by topics to facilitate user understanding, so that all data related to the same element of real life is linked together. For example, all customer data can be consolidated in the same table, all product data in another, and so on.

Integrated: the data must be integrated into a consistent structure, eliminating the inconsistencies involved between the various operational systems. The information is structured in various levels of detail to suit the needs of users. Some of the most common inconsistencies that we usually find are: in nomenclature, in units of measure, in date formats, multiple tables with similar information (for example, having several applications in the company, each with customer tables) .

Historical (time variant): the data, which may vary over time, must remain reflected in such a way that these changes are consulted and the reality that was at the time they were stored is not altered, thus avoiding the problem that occurs in the operational systems, that specifically only the state of the present business activity. A Data Warehouse must save the different values ​​that take a variable over time. For example, if a client has lived in three different cities, he must specify the period he lived in each of them and associate the facts (sales, returns, incidents, etc.) that occurred at any time to the city in which He lived when they occurred, and did not associate all historical facts with the city in which he currently lives. If a customer, during all the time we have been selling has gone through three civil states (single, married and divorced) we must know what marital status he had at the time we made each of the sales.

4 0
3 years ago
You are a computer Tech. You have been asked to solve a computer problem. The office manager says his computer not working corre
Nat2105 [25]

Answer:

1. Reboot computer .

2. If the issue persists, check if antivirus software is updated; if so, then verify if the problem is only with Office suite, try to save another Word, Excel, Power Point document and running other programs. If the problem is also extended to Excel or Power Point and other programs run properly then:

a. Uninstall Office Suite (documents and information won´t be lost)

b. Reinstall Office Suite  

c.      Run Word, Excel, etc.

Word documents should open properly.

Explanation:

The above procedure should solve the problem given that it was verified and discarded that the malfunction was caused by a virus and upon verifying that the problem was not only with Word, but all applications related to Office Suite, then by reinstalling the software any malfunction could be fixed.

7 0
3 years ago
Read 2 more answers
So, my school's account has been blocked, I can't get in and it tells me to contact and admin. I don't know why it happened, I'm
earnstyle [38]
This happened to me a while back. If you can’t find a contact to admin try emailing one of your teachers. My teacher told admin and then they fixed it.
8 0
3 years ago
The following method is intended to return true if and only if the parameter val is a multiple of 4 but is not a multiple of 100
Tresset [83]

Answer:

.isLeapYear (1900) will return an incorrect response

Explanation:

Given

The above method

Required

Which method call will give an incorrect response

(a) will return an incorrect response because 1900 is not a leap year.

When a year is divisible by 4, there are further checks to do before such year can be confirmed to be a leap year or not.

Since the method only checks for divisibility of 4, then it will return an incorrect response for years (e.g. 1900) that will pass the first check but will eventually fail further checks.

<em>Hence, (a) answers the question;</em>

5 0
3 years ago
What helps in determining the reliability of a person to repay debt?
faust18 [17]

C. The amount of credit score

3 0
3 years ago
Read 2 more answers
Other questions:
  • Regarding an intrusion detection system (IDS), stateful matching looks for specific sequences appearing across several packets i
    9·1 answer
  • Technician A says you should measure the parasitic load immediately after the vehicle is turned off. Technician B says you shoul
    10·1 answer
  • Write structured pseudocode to show the following: print “Reorder” when the quantity is less than 20; otherwise print “OK”.
    15·1 answer
  • Which of the following represent advantages of GPL-licensed software? Check all of the boxes that apply It is always free of cos
    12·2 answers
  • Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit f
    7·1 answer
  • What is your favorite anime?
    11·1 answer
  • El botón de layout se usa para <br>​
    8·1 answer
  • How to send an email to multiple recipients individually.
    9·1 answer
  • Python Programming
    6·1 answer
  • the 4gl languages that enable nonprogrammers to use certain easily understood commands to search and generate reports from a dat
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!