Question

Need in Python! Write a function definition named  power  that takes two formal parameters which can be assumed...

Need in Python!

Write a function definition named  power  that takes two formal parameters which can be assumed to be any numeric type. The first parameter is called base, the second is called exponent. The function should return the result of the base raised to the exponent power.    You may not use any Python math library functions inside your function. You may create your own code to test the function in an IDE if you wish.  

HINT: The exponent operator in Python is **. For example 3 ** 3 is 3 to the third power.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def power(base,exp):
b=base
for i in range(1,exp):
base=base*b
return base
  
base=int(input("Enter base: "))
exp=int(input("Enter exponent: "))

print(power(base,exp))

Add a comment
Know the answer?
Add Answer to:
Need in Python! Write a function definition named  power  that takes two formal parameters which can be assumed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program which defines a function named "divide_two_numbers" that accepts two numeric parameters and...

    Write a Python program which defines a function named "divide_two_numbers" that accepts two numeric parameters and divides the first parameter by the second. Your divide_two_numbers function must check the second parameter before dividing; if it is zero, raise an ZeroDivisionError exception which includes the string "second parameter was zero!" as a parameter instead of processing the division. Your main function must call your divide_two_numbers function at least twice; one call must use two normal parameters to verify normal operation, the...

  • In Python: Write the definition for a function named avg which accepts two int parameters, and...

    In Python: Write the definition for a function named avg which accepts two int parameters, and returns the average of the two values Write a statement that calls this function to print out the average of values 11 and 25.

  • In the space below, write a C function definition for a function named StrLower, which will...

    In the space below, write a C function definition for a function named StrLower, which will receive one parameter, a pointer to a null-terminated string (i.e., pointer to char), convert each character in the string to lowercase (using the tolower function from <ctype.h>), and return nothing to the caller. Inside the function definition, you may use a for loop or a while loop. If you use any variables other than the incoming parameter, you must define them locally in the...

  • RecursiveExponent.java Write a recursive function that accepts two arguments into parameters x and y, and which...

    RecursiveExponent.java Write a recursive function that accepts two arguments into parameters x and y, and which returns the value of x raised to the power y. Hint: exponentiation is equivalent to performing repetitions of a multiplication. For example, the base 4 raised to the 6th power = 4*4*4 * 4 * 4 * 4 = 4,096. The only file that you need to create is RecursiveExponent.java. Your main method should prompt the user to supply the base and exponent values...

  • Python Write a function (named largest_of_three) that takes three parameters and returns the largest. You can...

    Python Write a function (named largest_of_three) that takes three parameters and returns the largest. You can assume the parameters are either floats or ints.

  • Write only a python function definition for a function that takes two strings values as its...

    Write only a python function definition for a function that takes two strings values as its parameters , and if the first parameter alphabetically comes later in a dictionary than the second parameter then the function returns the length of the first parameter, otherwise the function returns the negative of the length of the second parameter. Name your function fA. For instance : fA(“do”,”can”) returns 2

  • Your task is to write a function definition for a function named non_vowel_words that takes a...

    Your task is to write a function definition for a function named non_vowel_words that takes a string as a parameter.  The function returns a setcontaining the words of the strings that do not start with a vowel (upper or lower case). The vowels are A, E, I, O, U. For full credit, make sure your implementation is pythonic, uses Python built-in capabilities and follows the Python style guide recommendations.  Please include a docstring for your function. You may test your function as...

  • Write the definition of a function named timeOnHighway that receives three parameters, all of type double: mileEndingPo...

    Write the definition of a function named timeOnHighway that receives three parameters, all of type double: mileEndingPoint , mileStartingPoint , and speed . The first two parameters indicate the mile markers on an interstate at which a vehicle goes to and starts at; the third parameter indicates the speed of the vehicle in miles per hour. The function returns the number of hours it takes a vehicle to go from the starting mile marker to the ending one. The function...

  • Python Write a function that takes in two numbers as parameters. The function will then return...

    Python Write a function that takes in two numbers as parameters. The function will then return the value of the first parameters squared by the second parameter. Print the value of the return statement. Take a screenshot of both your code and your properly executed code after you have run it. Submit the screenshots here along with your .txt file.

  • Python 3 Write a function named starCounter that takes three parameters: 1. a dictionary named starDictionary....

    Python 3 Write a function named starCounter that takes three parameters: 1. a dictionary named starDictionary. Each key in starDictionary is the name of a star (a string). Its value is a dictionary with two keys: the string 'distance' and the string 'type'. The value associated with key 'distance' is the distance from our solar system in light years. The value associated with key 'type' is a classification such as 'supergiant' or 'dwarf'. 2. a number, maxDistance 3. a string,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT