numpy-数组基本练习

输入整数n,创建一个包含12个数的数组,数组元素从n开始,依次递增(步长为1),输出该数组以及该数组中元素的最大值、和、标准差(保留两位小数)。

img


import numpy as np

n = int(input())
array = np.arange(n, n+12)  # 创建数组:n是起点,n+12是终点,步长默认1
Max = np.max(array)  # 最大值
Sum = np.sum(array)  # 和
Del = round(np.std(array, ddof=1), 2)  # 样本标准差

print("得到的数组是:", array)
print("最大值:", Max)
print("和", Sum)
print("标准差:", Del)