mirror of https://github.com/python/cpython
Make the example cut and pasteable.
This commit is contained in:
parent
a68bdc720a
commit
9aa1395916
|
@ -123,9 +123,9 @@ based on a set of ordered numeric breakpoints: 90 and up is an 'A', 80 to 89 is
|
|||
a 'B', and so on::
|
||||
|
||||
>>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
|
||||
... i = bisect(breakpoints, score)
|
||||
... return grades[i]
|
||||
...
|
||||
i = bisect(breakpoints, score)
|
||||
return grades[i]
|
||||
|
||||
>>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
|
||||
['F', 'A', 'C', 'C', 'B', 'A', 'A']
|
||||
|
||||
|
|
Loading…
Reference in New Issue