CP104 Lecture Notes - Lecture 22: Code Segment
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents
Document Summary
A function is a named reusable group of statements that perform a specific task: programming languages typically have a prewritten set of functions that are kept in a library, python v3 has 68 built in functions. Type (used in text in assigned readings) [y/n] : function call (input to bracket = function call) Can be called multiple times in a program. Can be stored in a library and used by other programs: task specific. Code segment is a smaller chunk of code. Easier to code, easier to read, easier to test: enables modular design. Development teams can work on different program segments at the same time writing your own function. Def function_name ([parameter1[, parameter2, ]]): (if no parameters, still need the brackets) o. Statement: statement o, return [value1[, value2, ]] Note: when reading computer notation, the square brackets are used to denote optional items.