Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 6, Problem 1D
Explanation of Solution
The two motivations for defining functions in your programs are:
- Reusability
- Abstraction
The first motivation is reusability:
- Once defined, a function can be used over and over and over again.
- User can save your work by invoking the same function many times in the program.
- Another aspect of reusability is that a single function can be used in several different and separate programs.
- When a user needs to write a new program, user can go back to your old programs, find the functions he/she needs, and reuse those functions in his/her new program.
- User can also reuse functions that somebody else has written...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In your own words, describe the two motivations for defining functions inyour programs.
Explain the difference(s) between calling a function by value and calling a function by reference, as well as when each should be used. What are the most significant distinctions between the two approaches of implementation?
How are local declarations stored in computer memory? Are there any reasons to avoid using local declarations if it is possible to achieve the same result without them? If reference parameters can be used in any function, why use value parameters at all? How are value parameters useful in processing data in a program?
Chapter 6 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 6 - Prob. 1TFCh. 6 - Prob. 2TFCh. 6 - Prob. 3TFCh. 6 - Prob. 4TFCh. 6 - Prob. 5TFCh. 6 - Prob. 6TFCh. 6 - Prob. 7TFCh. 6 - Prob. 8TFCh. 6 - Prob. 9TFCh. 6 - Prob. 10TF
Ch. 6 - Prob. 1MCCh. 6 - Prob. 2MCCh. 6 - Prob. 3MCCh. 6 - Prob. 4MCCh. 6 - Prob. 5MCCh. 6 - Prob. 6MCCh. 6 - Prob. 7MCCh. 6 - Prob. 8MCCh. 6 - Prob. 9MCCh. 6 - Prob. 10MCCh. 6 - Prob. 1DCh. 6 - Prob. 2DCh. 6 - Prob. 3DCh. 6 - Prob. 4DCh. 6 - Prob. 5DCh. 6 - Prob. 1PECh. 6 - Prob. 2PECh. 6 - Prob. 3PECh. 6 - Prob. 4PECh. 6 - Prob. 5PECh. 6 - Prob. 6PECh. 6 - Prob. 7PECh. 6 - Prob. 8PECh. 6 - Prob. 9PECh. 6 - Prob. 10PECh. 6 - Prob. 11PECh. 6 - Prob. 12PECh. 6 - Prob. 13PECh. 6 - Prob. 14PECh. 6 - Prob. 16PECh. 6 - Prob. 17PE
Knowledge Booster
Similar questions
- I am learning c++, and I get confused. I meet three questions, and one is asking to write a function header for a function named distance; the second question is to write the prototype for a function named distance, and the third question is to write a function call for a function named distance. I am wondering how to write different functions for these three questions? What are the differences between them? I am so confused.arrow_forwardLocal declarations are those that are kept in the memory of the computer; but, how exactly are they kept in memory? If reaching one's objective can be done without making use of local declarations, then doing so is a waste of time. Why bother using value parameters when you can just use references as your arguments in any function? How crucial are value parameters when it comes to the processing of programmed data?arrow_forwardI know the concept of function and programming well so no need to explain all that. I want to know if I can call a function inside another function or not in c++? If yes, please provide precise and direct code.arrow_forward
- If you have the time, it would be much appreciated if you could offer a more in-depth description of the function that metrics serve in the process of designing software. Everything has to have a description that is quite in-depth.arrow_forwardThe need for function prototypes in a program with user-defined functions begs the question, "why?"arrow_forwardUsing C++ Using your own creativity, make a set of function templates that have these features: This function must return a value. A function template with 2 template parameters, T1 and T2.And, any other parameters you want Within main (): Call your template functions and demonstrate how they work. Construct objects and show off your amazing programming skills!arrow_forward
- What are three things that need to happen when a subprogram returns to the function that called it?arrow_forwardFor C++, why is it that reference values can change when given to a function? I understand that if you make a const reference parameter like: double functionname(const point& p1) then the function cannot attempt to make a change to the parameter.arrow_forwardi need the answer quicklyarrow_forward
- A program uses a function named convert() in addition to its main function. The function main() declares the variable x within its body and the function convert declares two variables y and z within its body, z is made static. A fourth variable m is declared ahead(ie at top) of both the functions. State the visibility and lifetime of each of these variables. Write the code in C++ language. Thanks in advancearrow_forwardUsing C++ Using your own creativity, make a set of function templates that have these features: This function must return a value. A function template with 1 template parameter, T. And, any other parameters you want. A function template with 2 template parameters, T1 and T2. And, any other parameters you want Within main (): Call your template functions and demonstrate how they work. Construct objects and show off your amazing programming skills!arrow_forwardInvoking a function that takes many arguments, the order in which parameters are supplied is crucial.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning