Can someone explain the codes for these two situations?
(有人可以解释这两种情况的代码吗?)
Any help much appreciated. (任何帮助,不胜感激。)
I'm using a spyder anaconda console if that helps :slight_smile: (我正在使用spyder anaconda控制台,如果有帮助的话:slight_smile:)
- Given:
(鉴于:)
In []: import numpy as np
(在[]中:将numpy导入为np)
In []: x = (20*np.random.rand(5, 7))//2
(在[]中:x =(20 * np.random.rand(5,7))// 2)
Enter an expression which sets columns 1, 3, and 4 to 1.5.
(输入将第1、3和4列设置为1.5的表达式。)
Use advanced indexing combined with slicing for this. (为此,请结合使用高级索引和切片。)
- Given:
(鉴于:)
In []: import numpy as np
(在[]中:将numpy导入为np)
In []: x = np.zeros((5, 3))
(在[]中:x = np.zeros((5,3)))
In []: col = np.arange(5.0) ``
(在[]:col = np.arange(5.0)``)
Enter an expression which adds col to column 1 of x.
(输入一个表达式,将col添加到x的第1列。)
ask by sam translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…