# 周長 ```python= print(int(int(input())*2*3.14)) ``` # 浮點數位數 ```python= print(len(input().split('.')[1])) ``` # 格式化輸出 ```python= n = input() print(f'My name is {n}, it is {len(n)} characters.') ``` # 文字開頭、中間、結尾 ```python= while True: try: n = input() if len(n)%2: print(f'{n[0].lower()},{n[len(n)//2].lower()},{n[-1].lower()}') else: print(f'{n[0].lower()},{n[(len(n)-1)//2].lower()+n[(len(n))//2].lower()},{n[-1].lower()}') except: break ``` # 隱私文字 ```python= n = input().split() for i in range(len(n)): if 1 < i < len(n)-2: print('*'*(len(n[i])),end=' ') else: print(n[i],end=' ') ``` # 保持順序移動0 ```python= n = input().split(',') ans = ','.join([i for i in n if i!='0']) + ',' ans += ','.join([i for i in n if i=='0']) print(ans) ``` # 最常出現單字 ```python= d = {} s = input().lower().split() for i in s: if i not in d: d[i] = 1 else: d[i] += 1 l = [i for i in d if d[i] == max(d.values())] if len(l) != 1: print('No') else: print(l[0], d[l[0]]) ``` # 兩索引相加等於目標 ```python= while True: try: s, t = input().split() t = int(t) s = [int(i) for i in s.split(",")] flag = False for i in range(len(s)): for j in range(i+1, len(s)): if s[i]+s[j] == t: print(f"{i},{j}") flag = True break if flag: break except: break ``` # 在索引中插入值並保持順序 ```python= import bisect s, t = input().split() t = int(t) s = [int(i) for i in s.split(",")] print(bisect.bisect_left(s, t)) ``` # 序列中的美好組合總數 ```python= while True: try: s = [int(i) for i in input().split(",")] t = 0 for i in range(len(s)): for j in range(i+1, len(s)): if s[i]==s[j]: t += 1 print(t) except: break ```