* --Originally published at Programming*

Here we are going to create a program with two functions:

- def square_root(x): // returns the square root of x (float)
- def cube_root(x): // returns the cube root of x (float)

We should ask the user for a number and then, print the square and cube roots out.

So, here is the code:

First of all, we need to **import math** that is like call the library to come here (we need it, because it contents the functions). After that we write at the beginnig the functions we want. In this case I didn’t know how to code cube root, but remember that if we raise a number to one third it’s the same, so that’s what I did. We write **def **and the function. Then, in the next line what do you want it returns.

To continue, we start with our **main code**. We save what the user will introduce like an int and we are going to call it “**x**“.What about if the user enters a negative number? Well, I decided to send him a message, but if not, I continue with my programm (that is what we are evaluating in the **if-else**).

Now, to print the roots, first we have to make the operations, that is what we are doing in the **z** and **y** declaration. Finally, we just write a message to announce what we are doing plus the result.

And it’s ready It runs like this: