Explain at least one reason why programming languages have functions


Asked by wiki @ in Computers and Technology viewed by 227 People


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.

Answered by wiki @



Answer:

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.  


Do you know the better answer?

Similar Questions

Explain the differences between shade shading and shadow

Asked by wiki @ in Arts viewed by 202 persons

Explain the differences between shade, shading, and shadow.

How did the wilmot proviso lead to the civil war

Asked by wiki @ in History viewed by 138 persons

How did the Wilmot Proviso lead to the american civil war

What is the easiest way to double your money riddle

Asked by wiki @ in English viewed by 125 persons

Today's Riddle What is the easiest way to double your money?

How do you find the area of a rectangular prism

Asked by wiki @ in Mathematics viewed by 160 persons

How is the process of finding the surface area of a rectangular prism the same as finding the surface area of a triangular prism? How is it different? ANSWER: For …

How to find the rate of change of a function

Asked by wiki @ in Mathematics viewed by 160 persons

Given a graph of a function, explain how to find the rate of change and how to determine whether it is a linear or nonlinear function.

Which relation is a function of x

Asked by wiki @ in Mathematics viewed by 210 persons

Which relation is a function of x?

Why does the caged bird in maya angelou's poem sing

Asked by wiki @ in English viewed by 173 persons

Why does the caged bird in Maya Angelou's poem sing? A. to hear his song B. to show off C. to express itself D. to find a partner E. to …

Match the excerpts from frankenstein to the themes they reflect

Asked by wiki @ in English viewed by 223 persons

Match the excerpts from Frankenstein to the themes they reflect. ​

What must a country do to join the european union

Asked by wiki @ in History viewed by 185 persons

What must a country do to join the European Union?

How to determine if the slope is positive or negative

Asked by wiki @ in Mathematics viewed by 257 persons

Tell if the slope is positive, negative , zero , or no slope

Which way do you turn your wheels when parking downhill

Asked by wiki @ in English viewed by 171 persons

When parking on hills, your front wheels should be?

How to be a good mc at a talent show

Asked by wiki @ in Mathematics viewed by 184 persons

(02.01 MC) A talent show broadcast on television asks viewers to call in to vote for their favorite act. Describe how the design of the survey leads to bias. (4 …

How do bears get the energy and nutrients they need

Asked by wiki @ in Biology viewed by 211 persons

How do bears get their nutrients and energy they need

Which scenario is best illustrates the concept of illusory correlation

Asked by wiki @ in Physics viewed by 248 persons

Which scenario is best illustrates the concept of illusory correlation? A.A person argues that it is dangerous to climb mountains because several of her friends were injured while mountain climbing. …

What is the rule for adding integers with different signs

Asked by wiki @ in Mathematics viewed by 132 persons

Adding integers with different signs follows the same rules as multiplying and dividing integers with different sign. True or False?

When the ph of the extracellular fluid drops the kidneys

Asked by wiki @ in Medicine viewed by 285 persons

When the pH of the extracellular fluid drops, the kidneys a. secrete more hydrogen ions. b. secrete more bicarbonate ions. c. excrete fewer bicarbonate ions. d. secrete more hydrogen ions …

Which of the following is a characteristic of pure monopoly

Asked by wiki @ in Business viewed by 283 persons

Briefly state the basic characteristics of pure competition, pure monopoly, monopolistic competition, and oligopoly. Under which of these market classifications does each of the following most accurately fit? (a) a …

Explain and compare the concepts of comparative and absolute advantage

Asked by wiki @ in History viewed by 148 persons

What is the difference between comparative advantage and absolute advantage? A. Comparative advantage measures opportunity cost and absolute advantage measures efficiency.B. Absolute advantage measures opportunity cost and comparative advantage …

Estimate the product of 5 6 and 4 2 7

Asked by wiki @ in Mathematics viewed by 216 persons

Estimate the product of 5/6 and 4 2/7. Then find the product.

How to tell if a function is one to one

Asked by wiki @ in Mathematics viewed by 196 persons

Are exponential function one to one. How can you tell? What does this tell you about their inverses

How can a girl go 25 days without sleep riddle

Asked by wiki @ in Health viewed by 125 persons

How can a girl go 25 days without sleep? hint* Trick question!

Hoover dam on the colorado river is the highest dam

Asked by wiki @ in Mathematics viewed by 148 persons

Hoover dam on the colorado river is the highest dam in the united states at 221 m, with an output of 1300 mw. the dam generates electricity with water taken …

Textbooks should be replaced by ipads and online resources essay

Asked by wiki @ in English viewed by 118 persons

Student C made the claim, "Novels and textbooks should be completely replaced by iPads and online resources." Which of the following is an example of an appropriate counterclaim the student …

Solve the following pair of equations for x and y

Asked by wiki @ in Mathematics viewed by 203 persons

Consider the following pair of equations: y = x + 4 y = −2x − 2 Explain how you will solve the pair of equations by substitution. Show all the …

What angle does the ecliptic make with the celestial equator

Asked by wiki @ in Geography viewed by 161 persons

7. What is the angle between the ecliptic and celestial equator? Why is that important?

Organs are composed of tissues which are composed of cells

Asked by wiki @ in Biology viewed by 190 persons

Organs are composed of tissues, which are composed of cells. this is an example of which characteristic of life?

What is the distance from houston texas to austin texas

Asked by wiki @ in Mathematics viewed by 93 persons

On a map of Texas, the distance between Houston and Austin is 234 inches. The scale on the map is 1 inch = 50 miles. What is the actual distance …

How many miles can 2 gallons of gas get you

Asked by wiki @ in Mathematics viewed by 232 persons

If a 121 miles trip took 5 1/2 gallons of gas, how many miles can be driven with a full tank of 13 gallons

What is the key for a stem and leaf plot

Asked by wiki @ in Mathematics viewed by 215 persons

The key for a stem-and-leaf plot is 12|5 = 125. What is the stem for the data entry 556? A. 5 B. 6 C.55 D. 56

What are the two primes that are consecutive natural numbers

Asked by wiki @ in Mathematics viewed by 199 persons

List two primes that are consecutive natural numbers. can there be any​ others?

Most viewed questions in Computers And Technology


A customer wants to increase the storage capacity by 25gb

Asked by wiki @ in Computers and Technology viewed by 4716 persons


The following are ways to avoid having a collision except

Asked by wiki @ in Computers and Technology viewed by 1686 persons



Which internet protocol version is 100.0 0.256

Asked by wiki @ in Computers and Technology viewed by 1387 persons



Which item is not part of a college application everfi

Asked by wiki @ in Computers and Technology viewed by 1189 persons


Which one of these can connect directly to the internet

Asked by wiki @ in Computers and Technology viewed by 1180 persons



What makes a sequence of database operations a transaction

Asked by wiki @ in Computers and Technology viewed by 1134 persons


Which of the following is not true about mobile health

Asked by wiki @ in Computers and Technology viewed by 1070 persons



Cloud storage refers to the storage of data on

Asked by wiki @ in Computers and Technology viewed by 770 persons