【发布时间】:2023-03-29 05:30:01
【问题描述】:
我知道在 python 中你可以使用numpy.zeroes(size) 填充一个数组,但作为学习的一部分,我被要求不要使用numpy,所以我的问题是,有没有办法在没有numpy.zeroes 的情况下填充一个数组功能?
具体来说,如何在以下函数中用 0 填充以下列表?
def myHistWithRescale(listOfNums, maxInt):
"""Givne a list of real numbers in any range, first scale the numbers to
inters between 0 and maxInt (inclusive), then return the number of occurrences
of each integer in a list
"""
rescaledData = rescaleToInt(listOfNums, maxInt)
return counts
【问题讨论】:
-
标题似乎与方法中的注释不符。
-
该功能与问题有何关系?
标签: python