Computes xn using recursion and iteration

Assignment Help Python Programming
Reference no: EM132360821

Question :

Your assignment is to write a program that has two methods that computes xn using recursion and iteration. Remember xn is just x multiplied by itself n times. If n is 0 the result is defined to be 1, if n is one, the result is x, if n is two, the result is x times x, etc. The main program will solicit two numbers (x and n) from the user and call your x n method to compute
xn

X can be any decimal number, while n must be a non-negative integer. If a negative value is input for n, the program must display an error message and request input again until a legal value is input. When the method finally computes the value, it will return it to the main program which will display a message giving the original input numbers and the results of the power from the two functions (they had better be the same). It will then ask the user if he wants to determine x n for another pair of numbers.

Note that one method must use recursion to compute the value of xn, that is, the method calls itself until the value is computed. You can see a couple examples of recursion programs by looking at chapter 13 in your textbook. The other method must use iteration (a loop) to compute the value of xn.

As always make certain to have your name, the assignment number, and a brief description of theprogram in comments at the top of the program and have comments within the program.

Reference no: EM132360821

Questions Cloud

Share an example of words or phrases : Share an example of words or phrases from your organizations which you think someone outside the culture would not understand. Use your example in a sentence.
Weakness in the performance review process : What is the most serious weakness in the performance review process? How can it be changed?
Changes in market condition : Technology, globalization, changes in market condition, company growth.
Describe the hashing security mechanism : Describe the hashing security mechanism and its relationship to the encryption mechanism.
Computes xn using recursion and iteration : Write a program that has two methods that computes xn using recursion and iteration. Remember xn is just x multiplied by itself n times.
Written scripts in database from one environments : Compared and written scripts in database from one environments to other.Develop test strategy, test cases and test suites based on wireframes and defined system
Prepare a preliminary business report for the ceo : MPM701 – Business Process Management - Deakin University - prepare a preliminary business report for the CEO. The main body of your report must be structured
Create a class named animal thatis used to store information : InfoTc 1040 Introduction to Problem Solving and Programming Animal Class -Create a class named Animal thatis used to store information about an animal.
Department of labor occupational network : A role in which you are interested, and research that role within the U.S. Department of Labor's Occupational Network, also known as O*NET.

Reviews

Write a Review

Python Programming Questions & Answers

  Provide an example of an array

Provide an example of a ‘list'and explain how it would be used as part of a problem solution. Provide an example of an array.

  Write a program to find the area of a rectangle

Rewrite the below program to have a separate function for the area of a square, the area of a rectangle, and the area of a circle.

  Design and implement an english test

CSP1150 - Programming Principles - You are required to design and implement an "English Test" program in which the user is presented with a word and then asked to answer a simple question about the word. After 5 words, the program shows the user's..

  Write program that prompt user for strictly positive integer

Write a program that prompts the user for a strictly positive integer N, generates a list of N random integers between -50 and 50 (included)

  Look up terms in a tech dictionary

Create a program that allows a user to look up terms in a tech dictionary - programming or scripting that is of interest to you, and complete one or more web-based tutorials on the topic.

  Calculate the net salary of the employee

Calculate the net salary of the employee. To calculate the net salary, subtract federal and state tax from the gross salary. Calculate the state tax at 5%.

  Write a function to convert celsius to fahrenheit

Write a 2-part program as follows: Write a function to convert Celsius to Fahrenheit. Write a function to convert Fahrenheit to Celsius.

  Write a program that asks the user for 15 letters

Write a program that asks the user for 15 letters, accumulates them into a single string variable, and prints the string. The response paper should be in APA.

  Define a class person and its two child classes

Define a class Person and its two child classes: Male and Female. All classes have a method getGender which can print Male for Male class and Female for Female.

  Write a complete python program that prints a pyramid

Write a complete Python program that prints a pyramid with upside down triangle as shown. The program should be made of at least four functions without return.

  What relationships and properties do you need to model

Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard - What relationships and properties

  Develop an employee class that keeps data attributes

Develop an Employee class that keeps data attributes for the following pieces of information: Employee name and Employee number.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd