1. 程式人生 > >第七次作業

第七次作業

元組 out inside 字符串 have iss world 括號 ges

1.

big=‘‘‘i‘m a big big girl
in a big big world
it‘s not a big big thing if you leave me
but i do do feel
that i too too will miss you much
miss you much
i can see the first leaf falling
it‘s all yellow and nice
it‘s so very cold outside
like the way i‘m feeling inside
i‘m a big big girl
in a big big world
it;s not big big thing if you leave me
but i do do feel
that i too too will miss you much
miss you much
outside it‘s now raining
and tears are falling from my eyes
why did it have to happen
why did it all have to end
i‘m a big big girl
in a big big world
it‘s not a big big thing if you leave me
but i do do feel
that i too too will miss you much
miss you much
i have your arms around me ooooh like fire
but when i open my eyes
you‘re gone
i‘m a big big girl
in a big big world
it‘s not a big big thing if you leave me
but i do do feel
that i too too will miss you much
miss you much
i‘m a big big girl
in a big big world
it‘s not big big thing if you leave me
but i do feel i will miss you much
miss you much‘‘‘


for i in ‘,.\?!‘:
big=big.replace(i,‘ ‘)

words=big.split(‘ ‘)
print(words)

print(‘world :‘,big.count(‘world‘))
print(‘you :‘,big.count(‘you‘))
print(‘went :‘,big.count(‘went‘))
print(‘to :‘,big.count(‘to‘))
print(‘if:‘,big.count(‘if‘))

技術分享

2.


a=list(‘123113133‘)
print(‘列表‘,a)
for i in range(len(a)):
a[i]=int(a[i])
print(‘數值‘,a)

a.append(6)

print(‘增‘,a)

a.pop()

print(‘刪最後‘,a)


a[2]=1

print(‘改‘,a)

print(‘第一個3分的下標為:‘,a.index(3))


print(‘1分的同學有:‘,a.count(1))


print(‘3分的同學有:‘,a.count(3))

技術分享

3.

元組和字符串有很多共同的地方,一樣是不可變的,即不能修改元組。元組通過圓括號中用逗號分割的項目定義,元組通常用在使語句或用戶定義的函數能夠安全地采用一組值的時候。字符串可改變值。

第七次作業