20 lines
635 B
Python
20 lines
635 B
Python
import numpy as np
|
|
"""
|
|
This script demonstrates basic NumPy array manipulation:
|
|
- Updates product prices by assigning a value of 20 to all prices greater than 10.
|
|
- Modifies product ratings for two categories over three criteria by setting the last two criteria of the first category to 9.
|
|
- Prints the updated prices and ratings arrays.
|
|
"""
|
|
# Product prices
|
|
prices = np.array([15, 8, 22, 7, 12, 5])
|
|
# Assign 20 to every price greater than 10
|
|
prices[prices > 10] = 20
|
|
|
|
# Product ratings for two categories over three criteria
|
|
ratings = np.array([[6, 8, 9], [7, 5, 10]])
|
|
|
|
ratings[0, 1:] = np.array([9, 9])
|
|
print(prices)
|
|
print(ratings)
|
|
|