python學習-15 基本數據類型4

1.rangespa

a = range(0 ,100 , 5)          #建立>=0,<100的連續數字,步長爲5
for b in a:
 print(b)

運算結果:code

0
5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95

Process finished with exit code 0

 2.blog

text = input("請輸入:")
print("您輸入的數是:",text)
a = len(text)
print("",a,"")

r = range(0,a)
for b in r:
    print(b,text[b])

# 也能夠簡寫

###

text = input("請輸入:")
for b in range(0,len(text)):
print(b,text[b])
###

運算結果:input

請輸入:jaslkfaj
您輸入的數是: jaslkfaj
有 8 位
0 j
1 a
2 s
3 l
4 k
5 f
6 a
7 j

Process finished with exit code 0
相關文章
相關標籤/搜索