Rubywong123 commited on
Commit
f0ec026
1 Parent(s): ba43f0f

Upload numpy.txt

Browse files
Files changed (1) hide show
  1. numpy.txt +1 -49
numpy.txt CHANGED
@@ -119,54 +119,6 @@ try:
119
  except:
120
  print('Test failed...')
121
 
122
- Problem:
123
- I want to multiply the columns of A with the elements in X in the following order: the first element of X multiplies to the first column of A, the second element to the second column and so on.
124
-
125
- For example, given:
126
- import numpy as np
127
-
128
- X=np.array([10. , 2.46421304, 4.99073939, 5.79902063, 0. ]
129
- A=np.array([[0, 1, 1, 1, 0],
130
- [1, 0, 1, 0, 1],
131
- [1, 1, 0, 1, 1],
132
- [1, 0, 1, 0, 1],
133
- [0, 1, 1, 1, 0]])
134
-
135
- I want to produce:
136
- array([[0, 2.464, 4.991, 5.799, 0],
137
- [10, 0, 4.991, 0, 0],
138
- [10, 2.464, 0, 5.799, 0],
139
- [10, 0, 4.991, 0, 0],
140
- [0, 2.464, 4.991, 5.799, 0]])
141
-
142
- Note that the result should be kept 3 decimal places just as the example.
143
-
144
-
145
- A:
146
-
147
- <code>
148
- import numpy as np
149
-
150
- X=np.array([10. , 2.46421304, 4.99073939, 5.79902063, 0. ])
151
- A=np.array([[0, 1, 1, 1, 0],
152
- [1, 0, 1, 0, 1],
153
- [1, 1, 0, 1, 1],
154
- [1, 0, 1, 0, 1],
155
- [0, 1, 1, 1, 0]])
156
- ### BEGIN SOLUTION
157
- [insert]
158
- ### END SOLUTION
159
- print(B)
160
- </code>
161
-
162
- test:
163
- ans = np.round(A * X, 3)
164
- try:
165
- np.testing.assert_array_equal(ans, B)
166
- print('Test passed!')
167
- except:
168
- print('Test failed...')
169
-
170
 
171
  A1:
172
  Problem:
@@ -834,7 +786,7 @@ except:
834
 
835
 
836
 
837
- 9*.
838
  Score:
839
 
840
 
 
119
  except:
120
  print('Test failed...')
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  A1:
124
  Problem:
 
786
 
787
 
788
 
789
+ 9.
790
  Score:
791
 
792