PTA的Python練習題(八)

2022-04-29 15:27:10 字數 1088 閱讀 1383

從第3章-15 統計一行文字的單詞個數 繼續

字串是沒有下標的,所以c語言常用的冒泡法這裡不能用

a=input()

b=''

for i in

a:

if i not

inb:

b=b+i

c=list(b)

c.sort()

d=''

.join(c)

print(d)

所以這裡用了很多強制型別轉換,此外排序sort()函式只能用在list列表上,也需轉換

知識點:

3.笨辦法做題目:替換空格,再用空列表接收除了e的大小寫以外的字串

知識點:

PTA的Python練習題(十六)

第4章 15 換硬幣 挺難的,這裡學到乙個range的用法 也就是說range函式能實現順序和倒序,取決於step是正是負 count 0 x int input a x 5 for m in range a,0,1 b x m 5 2 for n in range b,0,1 c x 5 m 2 ...

PTA的Python練習題(六)

從 第3章 8 字串逆序 開始 不是很好做這道題,自己還是c語言的思維,網上幾乎也找不到什麼答案 濾掉5個字母,還有空格和感嘆號 a input count 0 for i in range 0,len a if a i a and a i e and a i i and a i o and a i...

python的練習題 Python練習題

1 使用while迴圈輸入1 2 3 4 5 6 8 9 10 i 0while i 10 i i 1 if i 7 continue print i 結果 e python python python test.py1 2 求1 100的所有數的和 i 0sum 0 while i 100 i 1...