[SOLVED] 程序代写代做代考 Programming Exercise 3-1

30 $

File Name: 程序代写代做代考_Programming_Exercise_3-1.zip
File Size: 461.58 KB

SKU: 2954225665 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Programming Exercise 3-1

Programming Exercise 12-7

# Global constants for minimum and maximum exponent values

MIN = 1

MAX = 100

def main():

# Local variables

num = 0.0

exp = 0

# Get the number as input from the user.

num = float(input(‘Enter a number: ‘))

# Get the exponent as input from the user.

while exp < MIN or exp > MAX:

exp = int(input(‘Enter a positive whole number between ‘

+ str(MIN) + ‘ and ‘ + str(MAX) + ‘: ‘))

# Call the power function and display the result.

print(num, ‘raised to the power of’, exp, ‘is’,

format(power(num, exp), ‘,.2f’))

# The power function uses recursion to raise a number to a power.

# The function accepts two arguments: the number to be raised and

# the exponent.

# The function assumes that the exponent is a nonnegative integer.

def power(x, y):

if y == 0:

return 1

else:

return x * power(x, y – 1)

# Call the main function.

main()

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 程序代写代做代考 Programming Exercise 3-1
30 $