Week 6 - Functions Flashcards

1
Q

What is a function?

A

Named sequence of statements that belong together.

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

What is a parameter?

A

Also known as Formal Parameter.
Must be a variable.
Specify what, if any, info you have to provide in order to use the function.

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

What is an argument?

A

Also known as Actual parameters.
It is the information that the function needs to work.
They are passed by the user.

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

What is the return statement?

A

Used at the end of a function’s body
Is followed by an expression which is evaluated
Terminates the function with a value

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

What are fruitful functions?

A

Functions that return a value.

Use the return statement

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

What are non-fruitful functions?

A

A function that does not return a value.

Does not use the return statement

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

What is an abstraction?

A

Refers to naming a concept.

Functions are abstractions

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

What is a concrete abstraction?

A

All details are visable

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

What is an abstract abstraction?

A

No details are visible, just a name

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

What is Generalisation?

A

It is when you add parameters to a function, which makes the function more general.

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

What are specific generalisations?

A

They do just one task.

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

What are general generalisations?

A

Can do many tasks

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

What are comments and how do you create?

A

Comments are notes for a programmer and can be thought of as documentation.
They can start with a # symbol or be enclosed in triple quotes ‘'’….’’’

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

What is a docstring and how do you create?

A

Docstrings clearly describe what the function does, so someone else can understand.
Can be known as documentation.
The are enclosed in triple quotes ‘'’…’’’ and are generally listed in the line following the function name.

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

What is unit testing and how do you use it?

A

A unit test will test what is returned in a function.
Import test needs to be completed.
The user needs to know the outcome.
test.testEqual(function_name(argument), result).

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