BNDS_ALEVEL_CS_20200228

落花浮王杯 提交于 2020-02-28 15:31:32

Question:在这里插入图片描述

# using range function
def listWithStep(startValue,endValue,step):
    for i in range(startValue + step,endValue + step,step):
        print(i)
    return 0

# using while loop
def listWithStep_while(startValue,endValue,step):
    i = start
    while (i < endValue and step >= 0) or (i > endValue and step < 0):
        i += step
        print(i)
    return  0

# main
if __name__ == "__main__":
    start = int(input("PLEASE INPUT START VALUE\n"))
    end = int(input("PLEASE INPUT END VALUE\n"))
    step = int(input("PLEASE INPUT STEP\n"))
    print("*----------using range function----------*")
    listWithStep(start,end,step)
    print("*----------using while loop----------*")
    listWithStep_while(start,end,step)
    pass
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!