In this article, I will talk about how to create a program with functions.
First, you need to import the math library.
After we need to wrote the functions to use , at the end of declaring the functions you will have to put return the value, in this case, you need 2:
def square_root(x): (to make square root)
def cube_root(x): (to make the cube root)
We have to ask the user what is the number to assess, at the same time declaring it as a variable.
Then you have to place an if ,in case the user decides to provide a negative number, which the program not explote.
For the end you need to print the results that gives to the operations and the programhave to mention «The program cannot handle negative numbers» if the user provide a negative number
These are the results.
Deja un comentario