Decomposition part 1 Flashcards
Top down approach (2)
What it helps you do+the steps
- reduces the complexity of the problem becaus eyou only have to work on it a portion of a time
- Start by outlining the major parts, then implement the solutions for each part, and debug
functions…..____ ______
does something (ex: prints sm on screen)
Things needed inorder to use functions: (2)
- function call
- function definition
Function call
- actually running the function
- ex: print(), input() ***specify the brackets dumbass
Function definition
- Instructions that indicate what the finction will do when it runs
To call a function that is prefefined
used the brackets “()”
Body of a function
- indented
- the instruction or group of instructions that execute when the function is called
the “def” in a function
not executable instruction
The program start at the first executable instruction that is
not indented
*documentation dont execute
How do functions faciliate code reuse?
Once the function definition is complete (and tested reasonably) it can be called (reused many times)
Rather than defining instructions outside of a function, the main starting execution point can also be defined explicitly as a function:
- with start functio
The starting function (2)
def main ():
def start():
local variable
created within the body of a function (indented)
global constants
created outside the body of a function
Only things that should be gloabl are
constants