Recall & Review
beginner
What is type promotion in numpy operations?
Type promotion is when numpy automatically converts data types during operations to a common type that can hold all values without loss.
Click to reveal answer
beginner
What happens when you add an integer array and a float array in numpy?
Numpy promotes the integer array to float type before adding, so the result is a float array.
Click to reveal answer
beginner
Why does numpy promote types during operations?
To avoid losing information by ensuring the result can represent all input values correctly.
Click to reveal answer
intermediate
What is the result type when you multiply a float32 array with an int64 array in numpy?
The result is promoted to float64 because numpy chooses a common type that can hold both values safely.
Click to reveal answer
intermediate
How does numpy handle type promotion with boolean and integer arrays?
Boolean values are promoted to integers (0 or 1) before the operation, so the result is an integer array.
Click to reveal answer
What type does numpy promote when adding int32 and float64 arrays?
✗ Incorrect
Numpy promotes to the more general type, float64, to avoid losing decimal information.
When multiplying a boolean array with an int array, what is the result type?
✗ Incorrect
Booleans are promoted to integers (0 or 1) before multiplication, so the result is integer.
If you add a float32 array and a float64 array, what will be the output type?
✗ Incorrect
Numpy promotes to the higher precision float64 to keep accuracy.
Why does numpy promote types during operations?
✗ Incorrect
Type promotion ensures no data is lost during operations.
What happens when you add an int8 array and a uint16 array?
✗ Incorrect
Numpy promotes to int32 to safely hold values from both types.
Explain how numpy decides the output data type when performing operations on arrays with different types.
Think about how numpy chooses a type that can hold all input values safely.
You got /4 concepts.
Describe what happens when you perform arithmetic operations between boolean and numeric numpy arrays.
Remember how True and False behave as numbers in numpy.
You got /4 concepts.