初心者向けのPythonのプログラミング問題です。入門編としてチャレンジしてください。Pythonの正答例は以下になります。
問題421
words = [“apple”, “banana”, “cherry”]
reversed_words = [word[::-1] for word in words]
print(reversed_words) # [‘elppa’, ‘ananab’, ‘yrrehc’]
問題422
numbers = [1, 5, 3, 9, 2]
numbers.sort(reverse=True)
print(numbers) # [9, 5, 3, 2, 1]
問題423
numbers = [1, 2, 3, 4]
doubled_numbers = [x * 2 for x in numbers]
print(doubled_numbers) # [2, 4, 6, 8]



コメント