Ask Question

In your own words, explain at least one reason why programming languages have functions. Include an example of something you did in this lesson that demonstrates the reason you describe.

+2
Answers (1)
  1. 14 March, 22:40
    0
    In programming, function is a block of codes which can be reused to perform a specific task. Functions are ubiquitous in many real world program. One reason why programming languages have functions is that the function can greatly reduce code redundancy. The codes that perform a specific task (e. g. addition), can be grouped into a function block. We just need to call the function name to run that block of code in any part of our program whenever necessary instead of keep writing the same block code over and over again.

    One example of function is given below:

    def addition (x, y):

    result = x + y

    return result

    To use the function above to perform addition, we just simply call the function name, addition (2, 5), by passing two values to parameter x and y and it will return addition result, 7. We can repeat the similar function calling by passing another parameters to it and get the addition result accordingly.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “In your own words, explain at least one reason why programming languages have functions. Include an example of something you did in this ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers