Unit 9 Flashcards

Functions

1
Q

9.2 - User-Defined Function Basics

What is a function?

A

a grouping of pre-defined statements used for repeated operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

9.2 - User-Defined Function Basics

What is a function definition?

A

creates/DEFINES a new function using def

ex. def calc_area()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

9.2 - User-Defined Function Basics

What is a function call?

A

using the function in code

ex. `print(calc_area(x, y))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

9.2 - User-Defined Function Basics

What is a return statement?

A

a single value that a function can return

functions only return ONE thing–including containers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

9.2 - User-Defined Function Basics

What is the difference between a parameter and an argument?

A

both serve as inputs for functions
parameter - anything
argument - number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

9.2 - User-Defined Function Basics

What is a nested function?

A

a function that calls another function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

9.2 - User-Defined Function Basics

What is a main function?

A

the primary section of code that eventually uses the other functions

AKA if \_\_name\_\_ == '\_\_main\_\_':

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

9.3 - Print Functions

What is a void function?

A

a function with no return value; often seen with functions that only print things

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

9.4 - Dynamic Typing

What is polymorphism?

A

adding together different types in a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

9.4 - Dynamic Typing

What is the difference between dynamic and static typing?

A

dynamic - determines the type of objects as a program (Python)
static - programmer must define the type for every variable & function parameter in source code (C, C++)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

9.5 - Reasons for Defining Functions

What is modular development?

A

dividing a program into seperate modules, then develop and test the modules seperately

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

9.5 - Reasons for Defining Functions

Why do programmers use functions?

A

makes programs easier to read and debug

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

9.7 - Function Stubs

What is incrimental development?

A

writing small amounts of code and testing it; adding code incrimentally

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

9.7 - Function Stubs

What are function stubs?

A

function definitions with unwritten statements

uses pass as a placeholder for functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

9.7 - Function Stubs

What does NotImplementedError do?

A

indicates a function isn’t implemented yet; stops execution of program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

9.7 - Function Stubs

What does pass do?

A

skips code; used for function stubs