小编Kim*_*Lee的帖子

Create an array of repeating elements that increase by 0.1 intervals

What I want my code to do is to create an array of elements: [13.8, 13.9, 14.,...] That increase by 0.1, but each of the elements should repeat 17 times before going on to the next number. Below is my code.

from numpy import*
from pylab import*
def f(elem):
return repeat((elem + 0.1),17)
print f(13.8)

def lst(init):
   yield init
   while True:
       next = f(init)
       yield next
       init = next

for i in lst(13.8):
    print i
    if i > 20:
        break …
Run Code Online (Sandbox Code Playgroud)

python arrays numpy scipy python-2.7

0
推荐指数
1
解决办法
3028
查看次数

标签 统计

arrays ×1

numpy ×1

python ×1

python-2.7 ×1

scipy ×1