初心者向けのPythonのプログラミング問題です。入門編としてチャレンジしてください。Pythonの正答例は以下になります。
問題157
text = “hello”
print(f”最後の文字は ‘text[-1]’ です”)
問題158
my_list = [1, 2, 2, 3, 4, 4, 5]
unique_list = list(set(my_list))
print(unique_list)
問題159
from collections import Counter
my_list = [1, 2, 2, 3, 4, 2, 5]
counter = Counter(my_list)
most_common = counter.most_common(1)[0][0]
print(f”最も頻繁に出現する数は most_common”)



コメント