Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
26 lines (21 loc) · 477 Bytes

File metadata and controls

26 lines (21 loc) · 477 Bytes
Copy raw file
Download raw file
Edit and raw actions
@author jackzhenguo
@desc 
@date 2019/4/14

71 浮点数等差数列

def float_range(start, stop, n):
    start,stop,n = float('%.2f' % start), float('%.2f' % stop),int('%.d' % n)
    step = (stop-start)/n
    lst = [start]
    while n > 0:
        start,n = start+step,n-1
        lst.append(round((start), 2))
    return lst

测试举例:

float_range(1, 8, 10) 
# [1.0, 1.7, 2.4, 3.1, 3.8, 4.5, 5.2, 5.9, 6.6, 7.3, 8.0]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.