Preview Cambridge IGCSE Computer Science Programming Book for Python

Page 39

Chapter 4: Subroutines

Summary ●

Subroutines provide an independent section of code that can be called when needed from another routine while the program is running. In this way subroutines can be used to perform common tasks within a program.

As an independent section of code, a subroutine is easier to debug, maintain or update than repetitive code within the main program.

Subroutines are called from another routine. Once they have completed execution they pass control back to the calling routine.

Subroutines can be passed values known as parameters.

A procedure is used to separate out repetitive code from the main program.

A function is a type of subroutine which can receive multiple parameters and return values.

29


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.