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]
2 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]2 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 tooltip is a _____________ that allows the programmer to create a small popup message that displays when the user places the m
Shalnov [3]
I believe a message
7 0
2 years ago
Read 2 more answers
Distinguish between the desktop publishing packages and multimedia packages​
maksim [4K]

Answer:

___________________________________________________________

Word processing software is used for working with text, while desktop publishing software involves production of documents that combine text with graphics. DTP software is perfect for making flyers, brochures, booklets. This type of software is usually more advanced than word processing apps.

___________________________________________________________

4 0
2 years ago
A company wishes to deploy a wireless network. Management insists that each individual user should have to authentic.ate with a
kap26 [50]

Answer:

A company wishes to deploy a wireless network. Management insists that each individual user should have to authentic.ate with a unique username and password before being able to associate with the wireless access points. Which of the following wireless features would be the MOST appropriate to achieve this objective?

Option A is the correct answer -  WPA2 PSK.

Explanation:

Data is the most essential asset for obtaining knowledge and information. Therefore, it has to be protected from various threats. However, the wireless network provides the option of sharing data without wires, but it is flying in the air. Thus, to secure it, we need to secure it with the right tools.

Option A: WI-FI Protected Access Pre-shared-Key (WPA2 PSK) is the best protection tool because it has 2 modes-PSK and Enterprise mode.

7 0
3 years ago
Read 2 more answers
Computer data that is suitable for text​
TiliK225 [7]

<em>Answer:</em>

<em>Answer:Data Types. Computer systems work with different types of digital data. In the early days of computing, data consisted primarily of text and ...</em>

3 0
3 years ago
Microsoft Word Module 3 the answers for online class University MIS
Artist 52 [7]

Answer:

Nope

Explanation:

You can use open office for free

7 0
3 years ago
Other questions:
  • WILL DO A BRAINLY! help pls.
    15·1 answer
  • Technological _____ is the term used to describe the merging of several technologies into a single device.
    13·1 answer
  • Discuss trends in cellular data transmission speeds
    15·2 answers
  • Given the following sets, for each set operation provide the elements of the resulting set in set notation or using a well-known
    5·1 answer
  • PLEASE HELP! One of the nice byproducts of joining a club, organization, community service project, or service learning project
    6·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • When you build a computer from parts, you usually start by deciding on which processor and motherboard you will use?
    11·1 answer
  • For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the re
    8·1 answer
  • In this unit, you learned how to manipulate numbers and strings, acquire input from the user, perform data manipulations for var
    10·1 answer
  • El botón de layout se usa para <br>​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!