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
Computer system with a 32-bit logical address and 4k-byte page size. assume that each entry of a page table consists of 4bytes.
Annette [7]

The number of bits in the physical address is 26 bits. The number of entries in a page table is \mathbf{2^{20}} entries. The size of the page table in a one-level paging scheme is 4MB.

<h3>
What is paging in Operating System?</h3>

Paging is a storage method used in operating systems to recover activities as pages from secondary storage and place them in primary memory. The basic purpose of pagination is to separate each procedure into pages.

We are given the following parameters:

  • 32-bit logical address
  • Page size = 4 KB = \mathbf{2^{12} \ bytes }
  • Size of each Page table entry = 4 bytes

Suppose the system supports physical memory size = 64 MB = \mathbf{2^{26} \ bytes}

Thus, the number of bits in the physical address is computed as:

= \mathbf{log_2 \{Physical-memory-size\}}

=\mathbf{log_2(2^{26})}}

= 26 bits

The number of entries in a page table = logical address space size/page size

The number of entries in a page table \mathbf{= \dfrac{2^{32}}{2^{12}}}

\mathbf{=2^{20}} entries

In a one-level paging scheme, the size of the table is:

= entire no. of page entries × page table size

= \mathbf{2^{20}\times 4 \ bytes}

= 4 MB

b.

suppose that this system supports up to 2^30 bytes of physical memory.

  • The size of the page table will be the same as 4 MB due to the fact that the number of entries, as well as, the page table entry size is the same.

Since the size of the page table surpasses that of a single page. A page cannot include a whole page table. Therefore, the page table must be broken into parts to fit onto numerous pages, and an additional level of the page table is required to access this page table.

  • This is called the Multi-Level Paging system.

Therefore, we can conclude that the number of bits in the physical address is 26 bits, the number of entries in a page table is \mathbf{2^{20}} entries, and the size of the page table in a one-level paging scheme is 4MB.

Learn more about Paging in Operating System here:

brainly.com/question/17004314

#SPJ1

4 0
1 year ago
You have to display or connect to network shares on remote computers. Which command-line utility will you use to accomplish the
Xelga [282]

Answer:

net use X: \\SERVER\Share

Explanation:

1. Connect securely to the remote computer or ensure you have access to it on the network

2. then follow the step below:

Where X: is the drive letter you wish to map the share to, and \\SERVER\Share is the UNC path to the share. This should make the share visible in My Computer and the command line as well like all other shares mapped through the GUI.

In order to later disconnect the share, you would use

net use X: /delete

8 0
3 years ago
The one who will defeat me in this typing race I will mark the one brainliest:
fredd [130]

Answer:

yes

Explanation:

can you send the link....

5 0
3 years ago
Read 2 more answers
The true or false questions.
DIA [1.3K]

Answer:

true

Explanation:

The command:

find -empty -type f -exec rm { } \;

carries out the following steps.

1) Finds all the empty files in the current directory and its subdirectories.

2) For each of the identified files, it executes the command specified as the parameter to exec option,namely, rm <filename>.

So effectively it removes all empty files in the directory tree starting at the current directory.  

7 0
3 years ago
Which of the following statements is not true? Group of answer choices
Nesterboy [21]

Answer:

A

Explanation:

Option A is not true because a Boolean variable type can hold one of two values only that is  (true/True or false/False).

All the other options given in the question are correct because

  1. A variable declaration refers to specifying its type and name
  2. If string variables are assigned a numeric values which is legal provided the values are enclosed in quaotes( " "), trying to carryout a mathematical operation like addition will result in string concatenation.
  3. The Variable name I_Love_to_eat_pizza is legal because it contains no special characters, doesn't start with a number and its not a reserved word in any language
4 0
3 years ago
Other questions:
  • You are the network administrator for Slimjim, a peripheral device company. The network uses Linux, and you need information on
    10·1 answer
  • What does the clone tile command do?
    15·2 answers
  • What is the effect of this program?
    5·1 answer
  • The algorithm and flowchart
    9·1 answer
  • A business that helps people find jobs for a fee
    12·1 answer
  • Icon view, list view, and details view are all common views provided by which kind of program?
    12·2 answers
  • Which option is typically only used when utilizing self joins?
    8·1 answer
  • Using a wireless technology known as ___, many smartphones can now be tapped on special payment devices to complete your purchas
    13·1 answer
  • Identify and explain groups that may be impacted by nanotechnology.
    13·1 answer
  • It refers to the story or events in which the film revolves.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!