Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function that computes th nth root of a number, where n can be an integer from 2-9. Your function should be named calculate_root,
Write a function that computes th nth root of a number, where n can be an integer from 2-9. Your function should be named calculate_root, take two input arguments (n and the number to take the root of), and return a statement giving the result.
end Now, it's your turn (again). Write a function that computes the nth root of a number, where n can be an integer from 2 to 9. Your function should be named calculate root, take two input arguments (n and the number to take the root of), and return a statement giving the result. Your input and output in the Command Window should look like this: > calculate root (2,16) The square root of 16.0000 is 4.0000 >> calculate root (3,27) The cube root of 27.0000 is 3.0000 >> calculate root (4,16) The fourth root of 16.0000 is 2.0000 Think about the limits on the roots allowed. How can you ensure that the input values for n are from 2 to 9 only? Return an error if somebody tries to take a root that's less than 2, greater than 9, or not an integer Are there other limitations on roots? Build in errors (with informative messages) to catch them Your input and output in the command window should look like this:
calculate_root(2,16)
The square root of 16.0000 is 4.0000
calculate_root(3,27)
The cube root of 27.0000 is 3.0000
calculate_root(4,16)
The fourth root of 16.0000 is 2.000
Think about the limits on the roots allowed. How can you ensure that the input values for n are from 2 to 9 only? Return an error if somebody tries to take a root that's less than 2, greater than 9, or not an integer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started