Table of Contents Show
1 Subroutines - Procedures and FunctionsLearn It: What are subroutines?Subroutines - In computer programming, a subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. In different programming languages, a subroutine may be called a procedure, a function, a routine, a method, or a subprogram. The generic term 'callable unit' is sometimes used. (Source Wikipedia.org) Parameters - Parameters or arguments are pieces of data that are passed into a subroutine in order for that subroutine to correctly function. In this example: def displayTotal(total): 'total' is a parameter that will be passed to the 'displayTotal' subroutine. Multiple parameters can be managed using commas, for example: def displayTotals(total1, total2, total3, etc)
Step 1
Step 2
Step 3
Learn It: Advantages of using Subroutines in programs
Advantages of using Subroutines
Learn It: Passing Data within ProgramsA parameter is a variable that is “passed” to a subroutine. Using Parameters to pass data within Programs
Learn It: Returning values from a SubroutineA parameter is a variable that is “passed” to a subroutine. Returning Single Values
Returning Multiple Values
Badge It: Coding ChallengeSilver - Return values from a subroutine
Upload to Fundamentals of 3.2 Programming - 3.2.7 Subroutines (Procedures and Functions): Silver on BourneToLearn Learn It: Local and Global VariablesGlobal Variables - A variable that is declared in the main program. Local Variable - A variable that is declared and only used in one subroutine. Using Local and Global Variables within Programs
Why use local variables?
Advantages of using Local Variables
Learn It: Functions and ProceduresFunctions and Procedures
Try It: Functions
Try It: Procedures
Learn It: Structured ProgrammingStructured Programming - Structured programming (sometimes known as modular programming) is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A defined function or set of similar functions is coded in a separate module or submodule, which means that code can be loaded into memory more efficiently and that modules can be reused in other programs.
Advantages of Structured Programming:
Badge It: Exam QuestionsGold - Answer the following questions:
Upload to Fundamentals of 3.2 Programming - 3.2.7 Subroutines (Procedures and Functions): Gold on BourneToLearn Badge It: Exam Question and Coding ChallengePlatinum - Exam question/Code Challenge
Upload to Fundamentals of 3.2 Programming - 3.2.7 Subroutines (Procedures and Functions): Platinum on BourneToLearn Which of the following is a benefit of procedures in programming?Which of the following is a benefit of procedures for programmers? Programmers can more easily understand programs with procedures, since procedures give names to complex pieces of code.
Why are procedures used in programming?Procedures can be used throughout a program, making them simpler and quicker to code. Using procedures has an added benefit. If something needs to be changed in a procedure, it only needs to be changed once, within the procedure code. This change will then appear wherever the procedure is used in the program.
Which of the following are benefits of procedural abstraction select two answers?Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers. Procedural abstraction makes it easier for people to read computer programs. Procedural abstraction eliminates the need for programmers to document their code.
What is a benefit of online collaborative software choose 1 answer?To summarise, the advantages of online collaboration include: Saving your business valuable time and resources. Increasing productivity so you can focus on the most important tasks. Improving communication within teams, between teams and with third parties.
|