Pythonは多肢選択問題にインタビューします



Python Interview Multiple Choice Questions



Tuples cannot compare sizes Complex numbers cannot compare sizes Print(3>2==2) The result is: True 3>2==2 is equivalent to (3>2)&(2==2) The difference between is and == Is: compare the memory address ==: Compare the comparison values

リストから重複する要素を削除します。

重複排除を実装するには2つの方法があります。 2番目の実装の重複排除は、元のリスト内の要素の相対的な順序を壊します。



newlist=[] for item in list: if item not in newlist: newlist.append(item) list1=[1,2,3,4] list2=list(set(list1))