Python Array Questions
Python Array Questions
1. Explain how to create arrays from numerical ranges using NumPy. Provide examples for
creating arrays with evenly spaced values and random values.
2. What is advanced indexing in NumPy? Describe the difference between basic slicing and
advanced indexing with relevant code examples.
3. Discuss broadcasting in NumPy. How does broadcasting work with arrays of different
shapes? Provide examples to illustrate your explanation.
4. How can you iterate over a NumPy array efficiently? Explain different methods of
iterating and their use cases.
5. Describe the various techniques for array manipulation in NumPy, including reshaping,
transposing, and joining arrays. Include examples for each technique.
6. What are binary operators in NumPy? Write a program demonstrating how binary
operations like AND, OR, and XOR can be performed on NumPy arrays.
7. Explain the use of string functions in NumPy. Provide examples showing how to perform
basic string operations like splitting, joining, and manipulating strings within an array.
8. Discuss the mathematical functions available in NumPy. Write a program using functions
like sin, cos, log, and exp on an array of values.
10. Explain how to handle special cases like NaN (Not a Number) and infinity in NumPy.
Write code that demonstrates how to detect and handle these values in an array.