Write a NumPy program to create random vector of size 15 and replace the maximum value by -1
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
x = np.random.random(15)
print("Original array:")
print(x)
x[x.argmax()] = -1
print("Maximum value replaced by -1:")
print(x)
Sample Output:
Original array: [ 0.04921181 0.83545304 0.4394982 0.81889845 0.8022234 0.46176053 0.95785815 0.86968759 0.35100099 0.00107607 0.4330148 0.56632168 0.57764716 0.09226267 0.01710047] Maximum value replaced by -1: [ 0.04921181 0.83545304 0.4394982 0.81889845 0.8022234 0.46176053 -1. 0.86968759 0.35100099 0.00107607 0.4330148 0.56632168 0.57764716 0.09226267 0.01710047]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال