Part 4, Organising your python code and data Flashcards
what are the steps in defining a function
this involves

- creating the header
1a. the function name
1b. the functions parameters - create the body, which holds the code the function will execute
what does the python help() function do
this will retrive the header of the function you put in as an argument and also retrive any docstrings held by that function
this is an object (such as an integer or string) that is unchanging and will always stand for itself.
NOTE: A variable is not a literal as it can change value and type at any time
what is a literal
to use these
- place a string surrounded by three quotation marks on each side as the first line of any functions or classes
how do you use docstrings in python
this is an expression constructed using basic expressions
what are constructed expressions
- The right hand side of the assignment is evaluated and an object is created for the expression
- The python interpreter checks to see if any other object is using the same named label
- If the label is not in use then the new label is created and attached to the object
Otherwise
- This label is removed from the object its currently attached to
- The label is then attached to the object that was created in step one
what is the process that python follows when assighning variables
this keyword can be used for debugging and testing purposes
what is the python assert keyword used for
how do you use docstrings in python
to use these
- place a string surrounded by three quotation marks on each side as the first line of any functions or classes
when writing a test function what should be included in the name of the function
- What the function does (a verb such as test)
- What it does it to (such as the function name you are testing)
this is made up of
- Its id
- Its type
- Its value

what three parts is a python object made up of
When the python interpreter reads through the code it will evaluate expressions and data items into objects. These objects are held inside the python interpreters memory

what does the python interpreter do to all data items when reading through the code
name 3 examples of constructed expressions and what they are constructed from
- Lists - constructed using literals
- Arithmetic operators - constructed using literals
- Function expressions - constructed using a function name and arguments
This can be used to find the type of an object
what is the python type() function used for
this will retrive the header of the function you put in as an argument and also retrive any docstrings held by that function
what does the python help() function do
what is text-driven development
This is the idea of writing tests before you write the code. The idea behind this is that it gives you a clearer understanding of what the code should do
- What the function does (a verb such as test)
- What it does it to (such as the function name you are testing)
when writing a test function what should be included in the name of the function
to use a function what 4 things should you know beforehand
- The name of the function
- What kind of arguments it needs
- What it gives back as a return value
- What other effects calling the function has (such as printing to console)
how does the python assert keyword work
this works by creating an assert statement which consists of
- the assert keyword
- a boolean expression
When the boolean expression evaluates to true nothing happens and the program continues running. However if the boolean expression evaluates to false then the program is halted and an assertion error error message is displayed

- Lists - constructed using literals
- Arithmetic operators - constructed using literals
- Function expressions - constructed using a function name and arguments
name 3 examples of constructed expressions and what they are constructed from
what is the python assert keyword used for
this keyword can be used for debugging and testing purposes
This can be used to find the id of an object
what is the python id() function used for
this is the parts that you know about, including
- name
- arguments
- return values
- any other effects/actions

explain the concept of a function interface
what are these known as
1. variables
2. literals
name 2 objects that are considered basic expressions
explain the concept of the function implementation
This is everything that goes on under the bonnet, it is not important to know what happens here just that you understand the interface

these are known as containers and the value of a container will consist of zero or more references or labels. Each reference or label is then attached to an element of the list such as a string or integer

what are lists in python known as and what will a list contain as it values
what is a literal
this is an object (such as an integer or string) that is unchanging and will always stand for itself.
NOTE: A variable is not a literal as it can change value and type at any time
- The name of the function
- What kind of arguments it needs
- What it gives back as a return value
- What other effects calling the function has (such as printing to console)
to use a function what 4 things should you know beforehand
what is the python type() function used for
This can be used to find the type of an object
this is a way that python helps you to document your code
what is a docstring in python
explain the concept of a function interface
this is the parts that you know about, including
- name
- arguments
- return values
- any other effects/actions

what are lists in python known as and what will a list contain as it values
these are known as containers and the value of a container will consist of zero or more references or labels. Each reference or label is then attached to an element of the list such as a string or integer

what is a docstring in python
this is a way that python helps you to document your code
what three parts is a python object made up of
this is made up of
- Its id
- Its type
- Its value

when using a function what are its three parts
this is made up off
- a name
- any arguments
- expression (the combination of the name and any arguments)

what does the python interpreter do to all data items when reading through the code
When the python interpreter reads through the code it will evaluate expressions and data items into objects. These objects are held inside the python interpreters memory

in python what are data items such as strings or integers known as
these are known as objects
this is made up off
- a name
- any arguments
- expression (the combination of the name and any arguments)

when using a function what are its three parts
name 2 objects that are considered basic expressions
what are these known as
1. variables
2. literals
what is the python id() function used for
This can be used to find the id of an object
what are constructed expressions
this is an expression constructed using basic expressions
these are known as objects
in python what are data items such as strings or integers known as
this works by creating an assert statement which consists of
- the assert keyword
- a boolean expression
When the boolean expression evaluates to true nothing happens and the program continues running. However if the boolean expression evaluates to false then the program is halted and an assertion error error message is displayed

how does the python assert keyword work
what is the process that python follows when assighning variables
- The right hand side of the assignment is evaluated and an object is created for the expression
- The python interpreter checks to see if any other object is using the same named label
- If the label is not in use then the new label is created and attached to the object
Otherwise
- This label is removed from the object its currently attached to
- The label is then attached to the object that was created in step one
This is everything that goes on under the bonnet, it is not important to know what happens here just that you understand the interface

explain the concept of the function implementation
this involves

- creating the header
1a. the function name
1b. the functions parameters - create the body, which holds the code the function will execute
what are the steps in defining a function
This is the idea of writing tests before you write the code. The idea behind this is that it gives you a clearer understanding of what the code should do
what is text-driven development