范围作为python中的输入

时间:2016-09-30 16:43:06

标签: python fibonacci

这是Fibonacci系列的简单程序。它适用于固定范围。但我想知道是否可以获得范围作为输入?如果是这样,请让我知道获取范围作为输入的语法。

xx=0

x=float (raw_input("enter the starting number:"))

r1=xx+x

print r1

r2=r1+x

print r2

r3=r1+r2

print r3

for i in range(10):

     r4=r2+r3

     print r4

     r2=r3

     r3=r4

"""寻找答案"""

1 个答案:

答案 0 :(得分:1)

就像你要求的起始号码一样:

number_of_outputs = int( raw_input('Enter the number of outputs: '))

#Your code goes here

for i in range(number_of_ouputs):

    #More code goes here