Answered step by step
Verified Expert Solution
Link Copied!

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.
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.
image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago

Question

What is computer neworking ?

Answered: 1 week ago