Instructions for the snippets test task.
This is markdown.
We can link to a rubric item and/or a snippet:
processData
function has to return the correct results.process.py
must work correctly when run with inputs.processData
function.Now
\
I'll
\
make
\
these
\
longer
\
so
\
the
\
rubric
\
get
\
pushed
\
down...
processData
def
to define processData
sorted
processData
, call sorted
in at least once place.processData
returns the correct result
processData
function is run must match the solution result.process.py
exhibits the correct behavior
process.py
as a whole file, the pattern of printed output based on inputs must match the solution's behavior.EXAMPLE
and DATA
variablesDATA
variable provided in the starter code.
In [ ]:EXAMPLE = [{'name': 'Two', 'order': 2}, {'name': 'One', 'order': 1}]
In [ ]:DATA = [{'name': 'A', 'order': 3}, {'name': 'B', 'order': 2}, {'name': 'C', 'order': 3}, {'name': 'D', 'order': 1}, {'name': 'E', 'order': 4}]
processData
should return for various inputs, using the EXAMPLE
and DATA
variables shown above.
In [ ]:processData([{'name': 'Two', 'order': 2}, {'name': 'One', 'order': 1}], 1)
Out [ ]:['One']
In [ ]:processData([{'name': 'Two', 'order': 2}, {'name': 'One', 'order': 1}], 2)
Out [ ]:['One', 'Two']
In [ ]:processData([{'name': 'Two', 'order': 2}, {'name': 'One', 'order': 1}], 3)
Out [ ]:['One', 'Two']
In [ ]:processData( [{'name': 'A', 'order': 3}, {'name': 'B', 'order': 2}, {'name': 'C', 'order': 3}, {'name': 'D', 'order': 1}, {'name': 'E', 'order': 4}], 3 )
Out [ ]:['D', 'B', 'A']
In [ ]: %run process.py
A or B? A
D
A or B? B
D, B, A