np.array([200, 250], dtype=np.uint8) plus 50, without wrapping

NumPy · from dtypes, precision and casting

int8/16/32/64uint8float32/64overflow.astypepromotionnp.iinfonp.isclose

Putting the kettle on…

Starting up…

Exercise 3

np.array([200, 250], dtype=np.uint8) plus 50, without wrapping. Values above 255 should stop at 255, and the result must still be uint8.

your answer
stuck? the lesson behind it
dtypes, precision and casting
Fixed-width boxes — and every surprise that follows from them.