...
/Part 3: Creating Functions for an Automatic Light Application
Part 3: Creating Functions for an Automatic Light Application
Learn about the possible ways of returning values from a function.
We'll cover the following...
Returning values from a function
We have previously created a function, but now we must check whether this function needs to return something. It calculates the distance, which we need to be outside of the function—so that value needs to be returned.
Again, we have two options. We can either return the value contained inside the variable distance like this:
Press + to interact
distance = 2 * earth_radius * asin(sqrt(a))return distance
Another option is to make this shorter, because in the previous example, the distance
variable is being used to hold the distance for one line. So, instead of ...