CSC108H5 Lecture Notes - Lecture 12: Structuring Element, Duplicate Code, Docstring

112 views4 pages
Verified Note
28 Nov 2018
School
Course
Professor

Document Summary

A function is a set of statements that performs a specific task. A function is a common structuring element allows that allows us to use a piece of code repeatedly in different parts of a program. Use of functions improve a program"s clarity and comprehensibility and makes it more efficient by reducing code duplication and breaking down complex tasks into manageable pieces. Function are also known as routines, subroutines, methods, procedures, subprograms. They can be passed as arguments, assigned to variables or stored in collections. A user defined python function or defined by def statement and follows the syntax: def function_name(parameter list): function body/statements. The indented statements make up the body of function and are executed when the. Once the function is called, parameters inside round brackets become arguments. Function bodies can have more than one return statement which may be placed anywhere within the function block.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents