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
kvv77 [185]
3 years ago
13

Python’s pow function returns the result of raising a number to a given power. Define a function expo that performs this task, a

nd state its computational complexity using big-O notation. The first argument of this function is the number, and the second argument is the exponent (nonnegative numbers only). You may use either a loop or a recursive function in your implementation.
Computers and Technology
1 answer:
weeeeeb [17]3 years ago
5 0

Answer:

The function is as follows:

def expo(num,n):

   prod= 1

   for i in range(n):

       prod*=num

       

   return prod

<em>The big-O notation is: O(n)</em>

Explanation:

This defines the function

def expo(num,n):

This initialzes the product to 1

   prod= 1

This iteration is perfomed n times

   for i in range(n):

The number is multiplied by itself n times

       prod*=num

       

This returns the calculated power

   return prod

To calculate the complexity.

The loop is repeated n times.

Each operation has a complexity O(1).

So, in for n number of operations; the complexity is: O(n * 1)

This gives: O(n)

You might be interested in
How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
loris [4]

Answer: How are you

Explanation:como estas meaning

3 0
3 years ago
To edit the text in a smartart graphic, what must be done first ?
ICE Princess25 [194]
C Hope this helps :D
8 0
3 years ago
Read 2 more answers
It is possible to turn extrinsic factors into intrinsic motivators. true or false
anygoal [31]
Definitely true. People who, for example, grew up homeless can use that as motivation to work harder in life.
8 0
3 years ago
Read 2 more answers
IT professionals ensure servers connected to the network operate properly. (2 points) True False
Nonamiya [84]

Answer:

True

Explanation:

Thats one of their most important jobs

3 0
3 years ago
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
Mashcka [7]

Answer:

Following are the code to this question:

def binarynumber(num):#defining a method binarynumber that accepts a parameter num

   x=""#defining a string variable x

   if (num!=0):#defining if condition to check number not equal to 0

       while (num>=1):#defining a loop that check value is grater then equal to one

           if (num %2==0):#defining if condition to check num is even

               x=x+"0" #add string value 0 in num variable

               num=num/2 #divide the value by 2

           else:#defining else block

               x=x+"1"#add string value 1 in num variable

               num=(num-1)/2#first subtract 1 into num variable then divide the value by 2

   else:

       x="0"#assign string value 0 in num variable  

   return "".join(reversed(x))#return value

num = int (input ("Enter any number: "))#defining num variable that input the integer value

print (binarynumber(num))#using print method to call method binarynumber with passing num parameter

Output:

Enter any number: 12

1100

Explanation:

  • In the above python code a method "binarynumber" is declared, in which the "num" variable passes as the parameter inside the method a string variable "x" is declared that stores all converted values.
  • Inside the method and if the block is declared that checks number value is not equal to 0 if this condition is false then it will add string value and reverse its value.
  • Or if the condition is true it defines a while loop that calculates the given number binary digits and returns its value.
  • At the last step, the num variable is declared that inputs the integer value from the user end and calls the method by using the print method.    
6 0
4 years ago
Other questions:
  • The program needs a Frisbee Golfer class.
    15·1 answer
  • What is the name of the malware included in CCleaner?
    11·1 answer
  • Which of the following is a scam in which a perpetrator sends an official looking e-mail that attempts to obtain a user’s person
    7·2 answers
  • Though there are no specific federal laws for cyberbullying, in some cases cyberbullying
    6·1 answer
  • A pre-design document you can use to create a new project quickly
    5·1 answer
  • The "great big secret" Ohanian talks about is the idea that:
    15·1 answer
  • Check ALL of the correct answers.
    13·1 answer
  • In excel online what is it called when you join connecting cells together to span across more than one column and/or row?
    7·2 answers
  • To what extent do you agree with the assertion that “Collection development begins with community analysis”. (Give reasons to bu
    7·1 answer
  • Which of the following is an example of machine learning?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!