Skip to content

Commit

Permalink
Merge pull request #1067 from fiveop/lists_arrays
Browse files Browse the repository at this point in the history
Do not refer to NumPy array using the term list
  • Loading branch information
ineelhere authored Nov 16, 2023
2 parents 082631c + b917cb6 commit a6859b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions episodes/10-defensive.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ This violates another important rule of programming:
## Pre- and Post-Conditions

Suppose you are writing a function called `average` that calculates
the average of the numbers in a list.
the average of the numbers in a NumPy array.
What pre-conditions and post-conditions would you write for it?
Compare your answer to your neighbor's:
can you think of a function that will pass your tests but not his/hers or vice versa?
Expand All @@ -467,9 +467,9 @@ can you think of a function that will pass your tests but not his/hers or vice v

```python
# a possible pre-condition:
assert len(input_list) > 0, 'List length must be non-zero'
assert len(input_array) > 0, 'Array length must be non-zero'
# a possible post-condition:
assert numpy.amin(input_list) <= average <= numpy.amax(input_list),
assert numpy.amin(input_array) <= average <= numpy.amax(input_array),
'Average should be between min and max of input values (inclusive)'
```

Expand Down

0 comments on commit a6859b9

Please sign in to comment.