Question

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.

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

In case of any query do comment. Thanks

Note: It seems from your question, you want a program to calculate power of firstnumber to secondnumber, For e.g. If first number is 15 and second number is 3 , it will calculate 153 which is 3375. If you need anything else, do let me know via comment. I will surely help you out.

Answer:

Code:

=============main.py=================

def calculatePower(firstNumber,secondNumber):
    result = 1
    #iterate over for loop from range(secondNumber) which will be 0 to secondNumber -1 times
    for i in range(secondNumber):
        result *= firstNumber
    return result
    

#main driver method
#you can input your number , I have used 15 and 3
result = calculatePower(15,3)
print(result)

===========Screen shot of the code for indentation and output=========

main.py 1. def calculate Power(firstNumber, secondNumber): 2 result = 1 3 #iterate over for Loop from range (secondNumber) wh

Add a comment
Know the answer?
Add Answer to:
Python Write a function that takes in two numbers as parameters. The function will then return...
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
  • python program please Write a function called backwards which takes two parameters. The first is a...

    python program please Write a function called backwards which takes two parameters. The first is a file object that has already been opened in read mode called essayfile. The second is called filename, which contains the filename for the output file that will need to be properly opened and closed in your function. The function should read from already opened file object line by line. Each line in the file should have the words on the line reversed. For example,...

  • Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the...

    Write a python function named displayFizzBuzz that takes a number as a parameter and DISPLAYS the appropriate FizzBuzz value for that number. Test this function on all of the numbers between 1 and 100000. Submit the code and a screenshot of the program running in Linux

  • Write a complete program that uses the functions listed below. Except for the printOdd function, main...

    Write a complete program that uses the functions listed below. Except for the printOdd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention to the order of your function calls. Be sure to read in data from the input file. Using the input file provided, run your program to generate an output file. Upload the output file your program generates. •Write a...

  • 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...

  • Using python, Write a function max3 that takes three numbers as its arguments and returns the...

    Using python, Write a function max3 that takes three numbers as its arguments and returns the greatest of these three numbers. Your submitted file for this problem should include (a) function definition, obviously, and (b) the code that calls that function (for this problem you do not have to package that calling code into the main() function although you may if you want to), so that if I run your *.py file it computes and prints something (e.g. few test...

  • Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the...

    Python 1 Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. 3 To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use...

  • Write a function named "write_string" that takes no parameters and doesn't return a value. This function...

    Write a function named "write_string" that takes no parameters and doesn't return a value. This function will write the string "hockey" to a file named "sacrifice.txt". If a named "sacrifice.txt" already exists it should be overwritten. (Python) Can you help me?

  • IN PYTHON Define a python function named remain to take two integer parameters and return the...

    IN PYTHON Define a python function named remain to take two integer parameters and return the remainder when the first integer is divided by the second. Multiple lines of code are required. Indicate indention when necessary with a few taps of the spacebar.

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • How to write python code that is a dice rolling function that generates random numbers. The...

    How to write python code that is a dice rolling function that generates random numbers. The dice rolling function takes two arguments: the first argument is the number of sides on the dice and the second argument is the number of dice. The function returns the sum of the random dice rolls. For example, if I call roll dice(6,2) it might return 7, which is the sum of randomly chosen numbers 4 and 3. It somewhere along the lines of:...

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
ADVERTISEMENT